Example : How to display message or popup message in Asp.net.
(i) Response.Write("Please Enter your name");
(ii) Response.Write("<script> alert('Please Enter your name')</script>");
(iii) Response.Write("<script> alert('Please Enter your name'); window.location = 'StuReg.aspx';</script>"); //Display Message first with Popup Window and then Page Redirect.
Example : How to close/exit application or browser in Asp.net.
(i)
protected void Close_Click(object sender, EventArgs e)
{
System.Environment.Exit(1);
//System.Environment.Exit(0);
}
(ii)
<asp:Button CssClass="btn btn-success" ID="submit" Text="Submit" runat="server" OnClientClick="window.close();"/>
Example : How to Redirect Page in Asp.net.
(i) Response.Redirect("StuReg.aspx");
(ii)Response.Redirect("/StuReg.aspx");
(iii)Response.Redirect("~/StuReg.aspx");
(iv)Response.Write("<script>window.location = 'StuReg.aspx';</script>");
Example : How to create user customized function to call multiple times in Asp.net using C#.
Trial.aspx.cs(C# file)
// public void cleardata()
void cleardata()
{
TxtSlno.Text = "";
TxtName.Text = "";
TxtPass.Attributes["value"]=TxtPass.Text = "";
TxtEmail.Text = String.Empty;
DateDob.Text = "";
RdbGender1.Checked = false;
RdbGender2.Checked = false;
ChkMatric.Checked = false;
ChkInter.Checked = false;
ChkGrad.Checked = false;
ChkPgrad.Checked = false;
TxrAdd.Text = "";
CmbCity.SelectedIndex = 0;
NmbPin.Text = "";
FileUpload1.Dispose();
TxtName.focus();
}
NB : To call/use created customized function -
protected void Reset_Click(object sender, EventArgs e)
{
cleardata();
}
0 Comments