views:

1473

answers:

3

hello, i want to call a server side method using __DoPostBack and generating the HTML, but i dont want a hidden ASP runat server control in my page its possible to call a server side method by its name not by the name of the control that trigger it ??

A: 

Whenever I see this question I get a little nervous that the asker doesn't quite understand all the implications of causing a post back, so I want to cover them briefly:

  • The current DOM instance in the browser is destroyed. As far as the browser is concerned you are submitting the current page and requesting a complete new one.
  • Not only will the server-side method in question run, but also the entire rest of the page lifecycle, including any required data binding or page Load/Init code. It will all be re-rendered from scratch.

Is that really what you want to happen?

Joel Coehoorn
A: 

well the same will occurs if i click a runatserver button, all the page will be render again.

i called the __DoPostBack javascript function with the name of the control as parameter and it works the same way if i click the button or linkbutton.

Yes, that does happen with a normal button as well. That's what has me concerned: that you were expecting it to run _only_ your specific method without rebuilding the page because you side stepped the normal process.
Joel Coehoorn
A: 

Look into various ways that ASP.Net handles AJAX functionality or callbacks for another term as this seems to be what you are trying to do. The method has to exist either within the page or if it is in a control, then an ID has to exist for that control to identify which button was clicked as one could repeat the same control many times on a page.

JB King