private void page_load (Object sender, system. eventargs E)
{
this.txt mediadate. attributes ["onblur"] = "_ dopostback ('" + this. linkbutton1.clientid + "','') ";
This. linkbutton1.attributes. cssstyle ["display"] = "NONE";
This. linkbutton1.click + = new eventhandler (mediadate_lostfocus );
}< SPAN class = "apple-converted-space">
private void mediadate_lostfocus (Object sender, eventargs E)
{
response. write ("wlsadfl ");
}< SPAN class = "apple-converted-space">
Http://blog.csdn.net/kucool/archive/2007/11/22/1898116.aspx
< Div >
< Input Type = "Hidden" Name = "_ Eventtarget" ID = "_ Eventtarget" Value = "" />
< Input Type = "Hidden" Name = "_ Eventargument" ID = "_ Eventargument" Value = "" />
< Input Type = "Hidden" Name = "_ Viewstate" ID = "_ Viewstate" Value = "/Wepdwullte4ndizmdg2ndrc kzmlhjobq9cycwbtbk + zrfzzkoh/I" />
</ Div >
< Script Type = "Text/JavaScript" >
<! --
VaR Theform = Document. Forms [ ' Form1 ' ];
If ( ! Theform) {
Theform=Document. form1;
}
Function _ Dopostback (eventtarget, eventargument) {
If ( ! Theform. onsubmit | (Theform. onsubmit () ! = False )) {
Theform. _ eventtarget. Value=Eventtarget;
Theform. _ eventargument. Value=Eventargument;
Theform. Submit ();
}
}
// -->
</ Script >
< Div >
In aspxCode:
< ASP: linkbutton ID = "Linkbutton1" Runat = "Server" Onclick = "Linkbutton#click" > Button1 </ ASP: linkbutton >
The source code in HTML is translated:
< A ID = "Linkbutton1" Href = "Javascript :__ dopostback ('linkbutton1 ','')" > Button1 </ A >
the above Code clearly shows that the linkbutton is just a hyperlink, the link is to execute JavaScript statements and call the backend code of the server by calling the _ dopostback function. Therefore, the _ dopostback function is automatically added to the page with a linkbutton.
but when we call the _ dopostback function, sometimes the script error" the object does not exist "will occur when we call this function? This is because there is no _ dopostback function body in HTML. When you drag and drop controls with the auto-return function, set the autopostback attribute to true, during running, the system automatically adds the _ dopostback function body. Of course, the most direct method is to add a linkbutton and set its text attribute to null. Do not set the visible attribute, if visible = false, the existence of linkbutton is ignored directly when translated into HTML.