trigger postback from popup window

B

Beffmans

Hi

I want to trigger a postback in my parent page from my popup window
which i opened with javascript. How to go about this?

ch Beffer
 
J

Jimmy

thanks but when i run it i get:

Compiler Error Message: CS0103: The name 'btnPostBack' does not exist in the
class or namespace 'ASP.WebForm1_aspx'

ch B.
 
T

Teemu Keiski

It's tested.

See the second line in my example, you do have a server-side Button which
has ID btnPostBack? Note that you can rename them freely as long IDs etc are
reflected where they are used.
 
J

Jimmy

i am trying:
Response.Write("<script>javascript:__doPostBack('','');</script>");

to force a postback on the parent page but it does not work??
 
J

Jimmy

i get an error after clicking the popupbutton :
'Object expected' line 9 char 2
that is on the line with :
<%=Page.GetPostBackEventReference(btnPostBack)%>

ch B
 
T

Teemu Keiski

Follow my example exactly as it is from line to line, so that you can see
how it works. After that, apply it for your scenario.

You cannot use Response.Write to write the __doPostBack call.
 
J

Jimmy

FYI what also works instead of :

<%=Page.GetPostBackEventReference(btnPostBack)%>

is:

__doPostBack('btnPostBack', '');

ch B.
 
T

Teemu Keiski

There's a good reason for it.

Yes, if some other control like LinkButton forces you to have __doPostBack
function declared on the Page, such snippet would be enough. But, by default
its not there if no control requires it. For example LinkButton calls to
Page.GetXXX methodsa to ensure that __doPostBack script is registered.

Page.GetPostBackEventReference ensures that __doPostback declaration is on
the Page as it registers it to be outputted. Better play explicitly. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top