Tuesday, 3 December 2013

ASP.NET Ajax UpdateProgress

UpdateProgress control shows the status information for the progress of the download occurring during the partial-page rendering in the UpdatePanel. The page can contain multiple UpdateProgress controls. Each one can be associated with a different UpdatePanel control. Alternatively, you can use one UpdateProgress control and associate it with all the UpdatePanel controls on the page. You can place UpdateProgress control either inside or outside the UpdatePanel controls. The following Asp.Net program shows how to an UpdateProgress control waits for completion of the task and during this waiting time it shows a .gif file as waiting message. Default.aspx



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<img alt="ajax-progress" src="http://asp.net-informations.com/ajax/img/ajax-progress.gif"></img>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
<br />
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>

Default.aspx.cs



using System;
using System.Web.UI;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(5000);
Label1.Text = "Server Time :  " + DateTime.Now.ToString();
}
}

Default.aspx.vb



Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
System.Threading.Thread.Sleep(5000)
Label1.Text = "Server Time :  " & DateTime.Now.ToString()
End Sub
End Class


ASP.NET Ajax UpdateProgress

Wednesday, 20 November 2013

Handling drop-down list in a PHP form

This tutorial will show you how to add select boxes and multi-select boxes to a form, how to retrieve the input data from them, how to validate the data, and how to take different actions depending on the input.


Select box


Let’s look at a new input: a “select” box, also known as a “drop-down” or “pull-down” box. A select box contains one or more “options”. Each option has a “value”, just like other inputs, and also a string of text between the option tags. This means when a user selects “Male”, the “formGender” value when accessed by PHP will be “M”.


<p>
Gender :
<select name="formGender">
<option value="">Select</option>
<option value="M">Male</option>
<option value="F">Female</option>
</select>
</p>

The selected value from this input was can be read with the standard $_POST array just like a text input and validated to make sure the user selected Male or Female.



<?php

if(isset($_POST['formSubmit']) )
{
$varMovie = $_POST['formMovie'];
$varName = $_POST['formName'];
$varGender = $_POST['formGender'];
$errorMessage = "";
}
?>

It’s always a good idea to have a “blank” option as the first option in your select box. It forces the user to make a conscious selection from the box and avoids a situation where the user might skip over the box without meaning to. Of course, this requires validation.



<?php

if(!isset($_POST['formGender']))
{
$errorMessage .= "<li>You forgot to select your Gender!</li>";
}

?>


Handling drop-down list in a PHP form

Saturday, 9 November 2013


Website Developement and PHP, .Net Training, Website Hosting by IT Company in Baroda


Best IT Company in Vadodara.
Provides Web Hosting, Website Development, Website Designing,
Live Project Training, PHP Training, .Net Training, WordPress and Ecommerce Training, Last sem Project Guidance for BCA,MCA,BE,Msc IT,Diploma Student.

Visit Our Website :-
www.paceinfonet.org
www.paceinfonet.com

502B, 6th Floor, Concorde Bldg., 
RC Dutt Road, Alkapuri, 
Vadodara - 390007, Gujarat ( india ) 

Phone : 0265 3051919 
Mobile : +91 - 8000195514

Thursday, 7 November 2013

jQuery Display Progress Bar on Button Click in Asp dotnet

Here I will explain how to use jQuery to show progress bar on button click in asp.net with example in c#, vb.net or jQuery show loading image on button click in asp.net using c#, vb.net.


To implement this we need to write the code like as shown below in your aspx page



<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>jQuery show progress bar on button click asp.net</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<style type="text/css">
.sample
{
background-color:#DC5807;
border:1px solid black;
border-collapse:collapse;
color:White;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div id="DisableDiv"> </div>
<input type="button" id="btnClick" value="Get Data" />
<div id="testdiv"></div>
</form>
<script type="text/javascript">
$(function() {
$('#btnClick').click(function() {
$('#DisableDiv').fadeTo('slow', .6);
$('#DisableDiv').append('<div style="background-color:#E6E6E6;position: absolute;top:0;left:0;width: 100%;height:300%;z-index:1001;-moz-opacity: 0.8;opacity:.80;filter: alpha(opacity=80);"><img src="loading.gif" style="background-color:Aqua;position:fixed; top:40%; left:46%;"/></div>');
setTimeout(function() { GetData() }, 1000)
})
});
function GetData()
{
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "ShowLoadingImageonButtonClick.aspx/BindDatatable",
data: "{}",
dataType: "json",
success: function(data) {
var theHtml = data.d;
$('#testdiv').html(theHtml)
$('#DisableDiv').html("");
},
error: function(result) {
alert("Error");
}
});
}
</script>
</body>
</html>

Now add following namespaces in code behind


C# Code



using System;
using System.Data;
using System.Data.SqlClient;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;

Once we add namespaces need write the code like as shown below

 protected void Page_Load(object sender, EventArgs e)
{
}
[WebMethod]
public static string BindDatatable()
{
GridView gv = new GridView();
System.IO.StringWriter stringWriter = new System.IO.StringWriter();
HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);
DataTable dt = new DataTable();
using (SqlConnection con = new SqlConnection("Data Source=SureshDasari;Initial Catalog=MySampleDB;Integrated Security=true"))
{
using (SqlCommand cmd = new SqlCommand("select UserId,UserName,Location from UserInformation", con))
{
con.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
}
}
gv.HeaderStyle.CssClass = "sample";
gv.DataSource = dt;
gv.DataBind();
gv.RenderControl(htmlWriter);
return stringWriter.ToString();
}

VB.NET Code


 



Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.Services
Imports System.Web.UI
Imports System.Web.UI.WebControls

Partial Class VBCode
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
End Sub
<WebMethod()> _
Public Shared Function BindDatatable() As String
Dim gv As New GridView()
Dim stringWriter As New System.IO.StringWriter()
Dim htmlWriter As New HtmlTextWriter(stringWriter)
Dim dt As New DataTable()
Using con As New SqlConnection("Data Source=SureshDasari;Initial Catalog=MySampleDB;Integrated Security=true")
Using cmd As New SqlCommand("select UserId,UserName,Location from UserInformation", con)
con.Open()
Dim da As New SqlDataAdapter(cmd)
da.Fill(dt)
End Using
End Using
gv.HeaderStyle.CssClass = "sample"
gv.DataSource = dt
gv.DataBind()
gv.RenderControl(htmlWriter)
Return stringWriter.ToString()
End Function
End Class

Aspdotnet_jquery1


aspdotnet_jquery2


aspdotnet_jquery3



jQuery Display Progress Bar on Button Click in Asp dotnet

Thursday, 24 October 2013

MySql Connection Strings in Ado.Net

Today, MySql is open source database in the world. In Ado.net to make connection to MySql , we have different connection strings. Basically it is not easy to remember different database connection strings in Ado.Net. So I am sharing some connection strings to connect to the MySql database using different drivers.


Using ODBC


// ODBC — MyODBC Driver — remote database

using System.Data.Odbc;

OdbcConnection conn = new OdbcConnection();

conn.ConnectionString = “Driver={MySql}; Server=db.domain.com; Option=131072; Port=3306; Stmt=; DataBase=DataBaseName; Uid=UserName; Pwd=Secret;” ;

conn.Open();


Using OLEDB


// OleDb

using System.Data.OleDb;

OleDbConnection conn = new OleDbConnection();

conn.ConnectionString = “Provider=MySqlProv; Data Source=ServerName; User id=UserName; Password=Secret”;

conn.Open();


Using .Net DataProvider


// .NET DataProvider from CoreLab

using CoreLab.MySql;

MySqlConnection conn = new MySqlConnection();

conn.ConnectionString =”Host=ServerName; DataBase=DataBaseName; Protocol=TCP; Port=3306; Direct=true; Compress=false; Pooling=true; Min Pool Size=0; Max Pool Size=100; Connection Lifetime=0;

User id=UserName;Password=Secret”;

conn.Open();



MySql Connection Strings in Ado.Net

Tuesday, 15 October 2013

PHP Project Training In Vadodara



Website Developement and PHP, .Net Training, Website Hosting by IT Company in Baroda

Best IT Company in Vadodara.
Provides Web Hosting, Website Development, Website Designing,
Live Project Training, PHP Training, .Net Training, WordPress and Ecommerce Training, Last semester Project Guidance for BCA, MCA, BE, Msc IT, Diploma Student.

Visit Our Website :-
www.paceinfonet.org
www.paceinfonet.com

502B, 6th Floor, Concorde Bldg.,
RC Dutt Road, Alkapuri,
Vadodara - 390007, Gujarat ( india )

Phone : 0265 3051919
Mobile : +91 - 8000195514 

Sunday, 6 October 2013

Display Random Header Images in WordPress

Display Random Header Images in WordPress


randomheaderimages


Most blog designs get boring if they have a huge header picture and it is static. This is when this tutorial comes in to make your header images dynamic because it rotates on each visit. You can select as many images as you want to rotate randomly. It brings life to a blog.


First you need to name your images in this format:



  • headerimage_1.gif

  • headerimage_2.gif

  • headerimage_3.gif


You must separate the name with an underscore. You can change the headerimage text to himage or anything you like.


Once you have done that paste the following code in your header.php where you would like the images to be displayed or in any other file.


<img src="http://path_to_images/headerimage_<?php echo(rand(1,3)); ?>.gif"
width="image_width" height="image_height" alt="image_alt_text" />

Make sure that you change the number 3 if you decide to do more than 3 images. This code is not exclusive for WordPress,

it will work with any php based platform.



Display Random Header Images in WordPress