inicio mail me! sindicaci;ón

The example of DoPostBack script function in ASP.NET

The application when the DoPostBack script function in ASP.NET says for today, ASPX page has include Asp:LInkButton perhaps contains AutoPostBack attribute and its value accuses for the server of True when, ASP.NET can create the scenario below automatically for the page:

It is quotative content below:
<input Type= "hidden" Name= "__EVENTTARGET" Id= "__EVENTTARGET" Value= "" />
<input Type= "hidden" Name= "__EVENTARGUMENT" Id= "__EVENTARGUMENT" Value= "" /> Function __doPostBack(eventTarget, eventArgument) { If(! TheForm.onsubmit | | (TheForm.onsubmit() ! = False)) { TheForm. __EVENTTARGET.value = EventTarget; TheForm. __EVENTARGUMENT.value = EventArgument; TheForm.submit();
}
}

__doPostBack contains two parameter: EventTarget and EventArgument.

EventTarget is to cause time send accuse ID, eventArgument is callback parameter (with accuse a relevant additional data) . These two parameter express only region __ EVENTTARGET and __ EVENTARGUMENT twice to save by hidden respectively.

Use these two hidden to express sheet to be able to search cause a page to answer send accuse an ID and answer the parameter when sending:

It is quotative content below:
Protected Void Page_Load(object Sender, eventArgs E)
{
String Target = Request.Params[”__EVENTTARGET” ];
String Args = Request.Params[”__EVENTARGUMENT” ];
}

Because of Asp:BUtton and Asp:IMageButton is not to use __doPostBack to answer send a page, use these two to accuse so time when sending a page, the code above is invalid.

Use HTML accuses time send a page:

It is quotative content below:
<form Id= "form1" Runat= "server" >
<asp:LInkButton ID= "LinkButton1" Runat= "server" ></asp:LInkButton>
<input Type= "button" Value= "Client Control" Onclick= "javascript:__doPostBack(’Button1’ , ’Button Click’);" />
</form> Protected Void Page_Load(object Sender, eventArgs E)
{ If(this.IsPostBack)
{ String Target = Request.Params[”__EVENTTARGET” ]; String Args = Request.Params[”__EVENTARGUMENT” ];
Response.Write(”Button ID: " Target "<br />" );
Response.Write(”Arguments: " Args "<br />" );
}
}

Affiliation destination is to make ASPX automatic create __doPostBack scenario.

Prevent Asp:BUtton submits a page:

It is quotative content below:

<form Id= "form1" Runat= "server ">
<asp:BUtton ID= "Button1" Runat= "server" Text= "Button" />
</form> Protected Void Page_Load(object Sender, eventArgs E)
{ String Scr = "return Confirm(’Are You Sure You Want To Submit This Form? ’);" ; This.Button1.Attributes.Add(”onclick” , scr);
}

Bookmark:Digg Del.icio.us Reddit

Leave a Comment