tags:

views:

324

answers:

2

I want to use a popup where I want to update 2 fields, either manually entered or populated from a drop dow list. So I need a popup with a submit button. I am experimenting with the code from the "How do I" videos. In the video they show a field being updated from a popup with a radiobutton list. I decided to change it so that instead of closing the popup in the radiobutton SelectedIndexChanged event, I removed that and put the code in a button submit event. However I get the message; Microsoft JScript runtime error: 'this._postBackSettings.async' is null or not an object The code is;


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head runat="server">
    <title>Untitled Page</title>
    <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
    <script language="javascript" type="text/javascript">
        function UpdateField(text)
        {
            var test = text + ' - SEND A MEETING REQUEST!';
            $get("MyTextBox").value = test;
//            $get("lblTest").value = test;
//            
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <div>
            <asp:UpdatePanel runat="server" ID="updTest">
                <ContentTemplate>
            <br />
            ToDo:
            <asp:TextBox ID="MyTextBox" runat="server" Width="538px"></asp:TextBox>
            <br />
            <asp:Panel ID="Panel1" runat="server" CssClass="popupControl" DefaultButton="btnTest">
                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                    <ContentTemplate>
                        <asp:RadioButtonList ID="RadioButtonList1" runat="server"                             Width="146px">
                            <asp:ListItem Text="Scott Guthrie"></asp:ListItem>
                            <asp:ListItem Text="Simon Muzio"></asp:ListItem>
                            <asp:ListItem Text="Brian Goldfarb"></asp:ListItem>
                            <asp:ListItem Text="Joe Stagner"></asp:ListItem>
                            <asp:ListItem Text="Shawn Nandi"></asp:ListItem>
                        </asp:RadioButtonList>
                        <div style="padding:10px;">
                            <asp:Button runat="server" ID="btnTest" Text="Submit" onclick="btnTest_Click"  />
                        </div>
                    </ContentTemplate>
                </asp:UpdatePanel>
            <br />
            <ajaxToolkit:PopupControlExtender ID="PopupControlExtender1" runat="server" CommitProperty="value"
                CommitScript="UpdateField(e.value);" PopupControlID="Panel1"
                Position="Bottom" TargetControlID="MyTextBox">
            </ajaxToolkit:PopupControlExtender>   
            </asp:Panel> 
            <div style="padding:20px;"><asp:Label runat="server" ID="lblTest" Text="Test"/>         </div>
                            </ContentTemplate>
            </asp:UpdatePanel>

        </div>
    </form>    
</body>
</html>



protected void btnTest_Click(object sender, EventArgs e)
{
    lblTest.Text = RadioButtonList1.SelectedItem.Text + " hello";
    PopupControlExtender.GetProxyForCurrentPopup(this.Page).Commit(RadioButtonList1.SelectedValue);
    // Reset the selected item
    RadioButtonList1.ClearSelection();

}
A: 

I don't see any ASYNC POSTBACK triggers in your panel... Might be worth a look.

Pace
+1  A: 

I found the answer here; http://forums.asp.net/p/1038571/1440433.aspx

The reply that worked was to set the button property; UseSubmitBehavior=false

Why this works I do not know. Who would have thought this would be the solution?

arame3333
This works because without that property the button will submit the form to the server instead of executing the necessary JavaScript.
Chris Shouts