IspostBack
IsPostBack will be false For the first time page loads,
When we click on any event at that time IsPostBack will be true.
if(!IsPostBack)
{
}
Showing alert Message in asp.net Codebehind
IsPostBack will be false For the first time page loads,
When we click on any event at that time IsPostBack will be true.
if(!IsPostBack)
{
}
Showing alert Message in asp.net Codebehind
protected void Page_Load(object sender, EventArgs e)
{
//This button click event is used to show alert message directly
ScriptManager.RegisterStartupScript(this,GetType(),"showalert","alert('Only
alert Message');",true);
// This button click event is used to show alert message from
JavaScript function
ScriptManager.RegisterStartupScript(this, GetType(),
"displayalertmessage", "Showalert();", true);
}
Display exception data in alert box
catch (Exception Ex)
{
Response.Write("<script>alert('" + Server.HtmlEncode(Ex.Message) + "')</script>");
}
Display exception data in alert box
catch (Exception Ex)
{
Response.Write("<script>alert('" + Server.HtmlEncode(Ex.Message) + "')</script>");
}
Multiple Email Id Validation in text box
suppose you are passing
multiple Email Id from textbox with semicolon (;)
^((\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)\s*[;]{0,1}\s*)+$
Regular Expression for PAN Card
[A-Z]{5}\d{4}[A-Z]{1}
WebUserControls
Web user controls are used for reusability
If we created web user control,That should be
registered in webform page
<%@ Register Src="~/WebUserControl.ascx" TagName="ImageViewer"
TagPrefix="uc"
%>
Src - It specifies
source of web user control.
TagPrefix - It Specifies Prefix for user control, i.e. Namespace to which it belong.
TagName - It Specifies Alias to the user control. i.e. Id to Control.
TagPrefix - It Specifies Prefix for user control, i.e. Namespace to which it belong.
TagName - It Specifies Alias to the user control. i.e. Id to Control.
Now, you need to add the control
<uc:ImageViewer ID="ImageViewer1"
runat="server"
/>
Call javaScript function in .cs file
.aspx
function
MyFunc()
{ alert("this is alert message callig from aspx");}
{ alert("this is alert message callig from aspx");}
.CS
ScriptManager.RegisterStartupScript(this, GetType(), "myF",
"MyFunc();", true);
HttpHandlers
In the simplest terms, an ASP.NET HttpHandler is a class that implements the System.Web.IHttpHandler interface.
ASP.NET HTTPHandlers are responsible for intercepting requests made to your ASP.NET web application server. They run as processes in response to a request made to the ASP.NET Site. The most common handler is an ASP.NET page handler that processes .aspx files. When users request an .aspx file, the request is processed by the page through the page handler.
HttpHandlers
In the simplest terms, an ASP.NET HttpHandler is a class that implements the System.Web.IHttpHandler interface.
ASP.NET HTTPHandlers are responsible for intercepting requests made to your ASP.NET web application server. They run as processes in response to a request made to the ASP.NET Site. The most common handler is an ASP.NET page handler that processes .aspx files. When users request an .aspx file, the request is processed by the page through the page handler.
ASP.NET offers a few default HTTP handlers:
- Page Handler (.aspx): handles Web pages
- User Control Handler (.ascx): handles Web user control pages
- Web Service Handler (.asmx): handles Web service pages
- Trace Handler (trace.axd): handles trace functionality
- You can create your own custom HTTP handlers that render custom output to the browser. Typical scenarios for HTTP Handlers in ASP.NET are for example
- delivery of dynamically created images (charts for example) or resized pictures.
- RSS feeds which emit RSS-formated XML
No comments:
Post a Comment