Another Strange Behavior in VS Design Mode RRS feed

  • Question

  • User1769015664 posted

    Do you see any thing wrong with the following code?

    I want to create a Button1_Click event for Button1 but the property page is grayed out in design mode. I manually created the event but clicking on button won't execute this code. I am trying to refresh a GridView on parent page from AJAX Popup is closed.

    protected void Button1_Click(object sender, EventArgs e)

            <asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" PopupControlID="Panl1" TargetControlID="lnkProcess"
            <asp:Panel ID="Panel10" runat="server" CssClass="Popup" align="center" style = "display:none">
                <iframe style=" width: 500px; background-color:lightsteelblue; height: 400px;" id="Iframe2" runat="server"></iframe>
                    (function () {
                        var pageurl = "WebForm1.aspx?Module=Mod1";
                        var txtCourseValue = document.getElementById("txtCourse").value;
                        if (txtCourseValue != undefined) {
                            document.getElementById("Iframe1").src = pageurl + "&Page=" + txtCourseValue;
                </script>           <br/>
                <asp:Button ID="Button1" runat="server" Text="Close" CausesValidation="False"/>

    Thursday, July 27, 2017 9:58 PM

All replies

  • User475983607 posted

    Yeah, you set the style to display: none.  Use the property window from the HTML code view to generated the click handler.

    Thursday, July 27, 2017 11:00 PM
  • User2103319870 posted

    Also set the button's UseSubmitBehavior property to false

     <asp:Button ID="Button1" runat="server" Text="Close" OnClick="Button1_Click" UseSubmitBehavior="false" />

    Thursday, July 27, 2017 11:31 PM
  • User-1838255255 posted

    Hi NJ2,

    According to your description, I noticed that you put the button inside the panel, but you set the property display of button to none. So I think this make it grayed out.

    Also I think about how to add click event to button, please check the following sample code:

    <asp:Button ID="Button1" runat="server" Text="Change" OnClick="Button1_Click" />
    Code Behind:
    protected void Button1_Click(object sender, EventArgs e)
     ProcessMyRequest(); }

    Best Regards,

    Eric Du

    Friday, July 28, 2017 4:37 AM