Button doesn' t work after control call back on the page

Source: Internet
Author: User

Today I want to fix a bug about viewvirtualdocument, and when clicking Cancel button it shoshould prompt a window about JavaScript but actually it can not work. So I debugging the program and find the problem is:

The page loads control on the page_load, and then excutes the codes of control, update the gridview, registes the Javascript into the button. at last excutes callback event. so problem happens, callback event does not deal with buttons, it only gets the data and response from server.

How to solve this problem?

I add a hiddenfield control into the subpagenavigationbar, every time when entering into the viewvirtualdocument page on the page_load, set the value like this:

_ Childrenchangedhidden = new hiddenfield ();
_ Browserspgw. Controls. Add (_ childrenchangedhidden );

Then registes JavaScript to cancel button on raisecallbackevent:

Bool ischanged = (this. virtualcontext. childrenmanager! = NULL & this. virtualcontext. childrenmanager. haschanged ());
_ Childrenchangedhidden. value = ischanged. tostring (). tolower ();

String script = string. Format ("Return avoidchildrenchangedconfirm ('{0}', '{1}');", _ childrenchangedhidden. clientid,

This. virtualcontext. virtualdocumentname. Replace ('\'',''));

_ Cancelbutton. Attributes. Add ("onclick", script );

And now it is in testing!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.