Postback from javascript

  • Thread starter Jeronimo Bertran
  • Start date
J

Jeronimo Bertran

I created a user control and I want to post back to the page when certain
events occur in the control.

I have been reading about doing this by assigning the
Page.GetPostBackEventReference to an event... however, in this case, the
call needs to be made inside the javascript code when one of the js
functions is called.

function finishUp()
{
ctlToPlaceValue.value = MyValue

alert(Page.GetPostBackEventReference());
}

how can I call the postback? I am also getting an error on the previous
code that Page is not defined.

Thanks

Jeronimo
 
M

Martin Kulov

Hi Jeronimo,

you have to rewrite your js function to something like this:

function finishUp()
{
ctlToPlaceValue.value = <%= MyValue%>

<%=Page.GetPostBackEventReference();%>;
}

Because Page object is server side object it will be accessible only before returning the html to the browser, i.e. when rendering the page. I assume you have the same case for MyValue variable.

Regards,
Martin Kulov
 

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

No members online now.

Forum statistics

Threads
473,813
Messages
2,569,699
Members
45,489
Latest member
SwethaJ

Latest Threads

Top