This is a migrated thread and some comments may be shown as answers.

Submit button not submitting form when setup as update control

1 Answer 76 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
skiik
Top achievements
Rank 1
skiik asked on 06 Sep 2008, 02:20 PM
using radajaxmanager I want to have a submit button as an updated control during ajax postback of another button. However when i add the submit button as an update control, it ajaxifys and will no longer postback.

The reason why i need to submit button as an updated control for another controls postback is because i want to conditionally add confirm attribute to the submit depending on settings of other controls on the form.  Any help appreciated. A test program is included below

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
        <telerik:RadScriptManager ID="RadScriptManager1" Runat="server"
            OutputCompression="AutoDetect">
        </telerik:RadScriptManager>
        <br />
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button"
            UseSubmitBehavior="False" />
&nbsp;<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        <br />
        <br />
        <br />
        <asp:Button ID="Button2" runat="server" Text="Form Submit" />
        <br />
        <br />
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="Button1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="Button1"
                            LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="Label1" />
                        <telerik:AjaxUpdatedControl ControlID="Button2" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" Runat="server"
            height="75px" width="75px">
            <img alt="Loading..."
                src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>'
                style="border:0px;" />
        </telerik:RadAjaxLoadingPanel>
   
    </div>
    </form>
</body>
</html>


        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                Session["bool"] = false;
            }
            Button2.Attributes.Clear();
        }
        public bool BoolVal
        {
            get
            {
                return (bool)Session["bool"];
            }
            set
            {
                Session["bool"] = value;
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            BoolVal = !BoolVal;
            if (BoolVal)
            {
                Label1.Text = "Enabled";
                Button2.Attributes.Add("onclick", "return confirm('button enabled. sure you want to continue?')");
            }
            else
                Label1.Text = "Disabled";
           
        }

1 Answer, 1 is accepted

Sort by
0
Konstantin Petkov
Telerik team
answered on 08 Sep 2008, 06:04 AM
Hello skiik,

You can still add client confirmation ability to the second button as explained here. Alternatively you can see how to exclude control from ajaxifying.

Sincerely yours,
Konstantin Petkov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Ajax
Asked by
skiik
Top achievements
Rank 1
Answers by
Konstantin Petkov
Telerik team
Share this question
or