Using doPostBack in asp.net

I want to use the doPostBack function in my link. When a user clicks on it, it will not be redirected to another page, and the page will be postback. I use this code, but it does not work. Where did I miss?

< a id="Sample" href="javascript:__doPostBack('__PAGE','');">



 function __doPostBack(eventTarget, eventArgument)

  {
           var theform = document.ctrl2

           theform.__EVENTTARGET.value = eventTarget

           theform.__EVENTARGUMENT.value = eventArgument

           theform.submit()
       }
+5
source share
4 answers

Try the following:

System.Web.UI.HtmlControls.HtmlAnchor myAnchor = new System.Web.UI.HtmlControls.HtmlAnchor();
string postbackRef = Page.GetPostBackEventReference(myAnchor);
myAnchor.HRef = postbackRef;
+1
source

__ doPostBack is an automatically generated function that ensures that the page is sent to the server to maintain the state of the page. It is not intended to redirect ...

window.location.href="yourpage.aspx" javascript Response.Redirect( "yourpage.aspx" ) , .

+1

? , AJAX.

0

ok, datagrid, , datagrid ( datagrid, column.it - ​​ , wikipedia's.The , UpdatePanels).

str = regex.Replace(str, "(: < a href=" "javascript:" Page.GetPostBackEventReference(Me) " > < font color =" "# CC0000" " > $1 </a> )" )

If I use window.location.href, it will discard the whole page. My goal is to send back only the datagrid (Ofcourse, taking the link text as output too). I do not use Frames, and the link is not a button. can i do this?

0
source

All Articles