Lost of data on postback

2 posts, 0 answers
  1. Mathieu
    Mathieu avatar
    13 posts
    Member since:
    Dec 2007

    Posted 20 Jan 2008 Link to this post

    Hi there,
    Is my situation.
    I have a page container which contain 2 userControl:

    <asp:ScriptManager ID="ScriptManager1" runat="server" />   
                <input type="hidden" id="hidJs" runat="server" /> 
                <div class="centerMain" > 
                    <div class="main">  
                        <div class="header">  
                            <div class="logo">  
                                <img  src="images/logo.png" onclick="window.location='login.aspx'" style="cursor:pointer" /> 
                            </div> 
                        </div> 
                        <img src="images/tabOnLeft.png" /> 
                        <div style="background-image:url(images/tabOnMid.png);height:26px;color:#FFF" > 
                            <div style="font-size:12px;line-height:26px" id="title" runat="server"><asp:Literal ID="Literal15" runat="server" Text="<%$ Resources: registration, signupProcess %>" /></div>  
                        </div> 
                        <img src="images/tabOnRight.png" /> 
                        <div class="bgContainer990" > 
                            <div class="bg990">  
                                <div id="div1" runat="server"><uc1:testUserctl id="uc1" runat="server"></uc1:testUserctl></div>  
                                <div id="div2" runat="server" style="display:none"><uc2:hq id="uc2" runat="server"></uc2:hq></div>      
                            </div> 
                        </div> 
                    </div> 
                </div> 
                 <telerik:RadAjaxManager id="RadAjaxManager1" runat="server"></telerik:RadAjaxManager> 

    In the codebehind i have the following:
    protected void Page_Load(object sender, EventArgs e)  
            {  
                //Get the WebUserControl  
                    Control ctlReg = (Control)Page.FindControl("testUserctl");  
                    //Get user control's button and label  
                    HtmlButton MyButton1 = (HtmlButton)ctlReg.FindControl("btnAccept");  
                    RadAjaxManager1.AjaxSettings.AddAjaxSetting(MyButton1, div1);  
                    RadAjaxManager1.AjaxSettings.AddAjaxSetting(MyButton1, div2);  
            } 

    So, in my in my userControl1 have a button call : btnAccept, which once press, will set the display to "none" to the userControl1 and set the display to "inline" to the userControl2.

    Here's parte the html of my userControl1 
    <div class="text12_383838" style="width:100%"><asp:Literal ID="Literal16" runat="server" Text="<%$ Resources: registration, personnal %>" /></div>  
            <div class="block">  
                <div class="text11_707070_Login"><asp:Literal ID="Literal17" runat="server" Text="<%$ Resources: registration, firstName %>" /></div>  
                <img src="images/textbox/txtLeft.png" alt="img" style="margin-left:10px;" id="imgtxtNoBlankFirstNameLeft" /> 
                <input type="text" class="dpTextbox" style="width:230px;" id="txtNoBlankFirstName" onblur="removeLeadingTrailingSpaces(this);document.getElementById('txtNoBlankCCFirstName').value=this.value" runat="server" maxlength="50" /> 
                <img src="images/textbox/txtRight.png" alt="img" id="imgtxtNoBlankFirstNameRight" /> 
            </div> 
            <div class="block">  
                <div class="text11_707070_Login" ><asp:Literal ID="Literal18" runat="server" Text="<%$ Resources: registration, lastName %>" /></div>  
                <img src="images/textbox/txtLeft.png" alt="img" style="margin-left:10px" id="imgtxtNoBlankLastNameLeft" /> 
                <input type="text" class="dpTextbox" style="width:230px" id="txtNoBlankLastName" onblur="removeLeadingTrailingSpaces(this);document.getElementById('txtNoBlankCCLastName').value=this.value" runat="server" maxlength="50" /> 
                <img src="images/textbox/txtRight.png" alt="img" id="imgtxtNoBlankLastNameRight" /> 
            </div> 
            <div class="block">  
                <div class="text11_707070_Login" ><asp:Literal ID="Literal19" runat="server" Text="<%$ Resources: mainApp, username %>" /></div>  
                <img src="images/textbox/txtLeft.png" alt="img" style="margin-left:10px" id="imgtxtNoBlankUsernameLeft" /> 
                <input type="text" class="dpTextbox" style="width:230px" id="txtNoBlankUsername" runat="server" maxlength="12" onblur="removeLeadingTrailingSpaces(this);" /> 
                <img src="images/textbox/txtRight.png" alt="img" id="imgtxtNoBlankUsernameRight" /> 
            </div> 
            <telerik:RadToolTip runat="server" EnableEmbeddedSkins="false"  IsClientID="true" Text="<%$ Resources: mainApp, toolTipPassword %>" Position="TopCenter" Skin="Vista" ID="RadToolTip1" TargetControlID="tooltip1" Width="200px" Height="50px" ></telerik:RadToolTip> 
            <div class="block" id="tooltip1">  
                <div class="text11_707070_Login" ><asp:Literal ID="Literal20" runat="server" Text="<%$ Resources: mainApp, password %>" /></div>  
                <img src="images/textbox/txtLeft.png" alt="img" style="margin-left:10px" id="imgtxtNoBlankPasswordLeft" /> 
                <input type="password" class="dpTextbox" style="width:230px" id="txtNoBlankPassword" runat="server" maxlength="12" onblur="removeLeadingTrailingSpaces(this);" /> 
                <img src="images/textbox/txtRight.png" alt="img" id="imgtxtNoBlankPasswordRight" /> 
            </div> 
            <div class="block">  
                <div class="text11_707070_Login" ><asp:Literal ID="Literal21" runat="server" Text="<%$ Resources: registration, passConfirmation %>" /></div>  
                <img src="images/textbox/txtLeft.png" alt="img" style="margin-left:10px" id="imgtxtNoBlankPasswordConfLeft" /> 
                <input type="password" class="dpTextbox" style="width:230px" id="txtNoBlankPasswordConf" runat="server" maxlength="12" onblur="removeLeadingTrailingSpaces(this);" /> 
                <img src="images/textbox/txtRight.png" alt="img" id="imgtxtNoBlankPasswordConfRight" /> 
            </div> 
            <div class="block">  
                <div class="text11_707070_Login">Secret question</div> 
                <img style="margin-left:10px;" src="Prometheus/Vista/ComboBox/dropBoxLeftOFF.gif" id="imgselNoBlankSecretQ_Input" /> 
                <telerik:RadComboBox Width="239px" DropDownWidth="450" EnableEmbeddedSkins="false" Skin="Vista" ID="selNoBlankSecretQ" runat="server"></telerik:RadComboBox> 
            </div> 
            <telerik:RadToolTip runat="server" EnableEmbeddedSkins="false"  IsClientID="true" Animation="Fade" Text="<%$ Resources: mainApp, toolTipSecretAnswer %>" Position="TopCenter" Skin="Vista" ID="RadToolTip2" TargetControlID="tooltip2" Width="200px" Height="50px" ></telerik:RadToolTip> 
            <div class="block" id="tooltip2">  
                <div class="text11_707070_Login" ><asp:Literal ID="Literal22" runat="server" Text="<%$ Resources: registration, secretAnswer %>" /></div>  
                <img src="images/textbox/txtLeft.png" alt="img" style="margin-left:10px" id="imgtxtNoBlankSecretAnswerLeft" /> 
                <input type="text" class="dpTextbox" style="width:230px" id="txtNoBlankSecretAnswer" runat="server" onblur="removeLeadingTrailingSpaces(this);" /> 
                <img src="images/textbox/txtRight.png" alt="img" id="imgtxtNoBlankSecretAnswerRight" /> 
            </div> 
            <div class="block">  
                <div class="text11_707070_Login" ><asp:Literal ID="Literal23" runat="server" Text="<%$ Resources: registration, gender %>" /></div>  
                <div class="radio selected" style="margin-left:10px" onmousedown="effect(this)" onmouseup="handle(this)" onmouseout="startClearing()">  
                    <input type="radio" runat="server" id="radFemale" value="1" class="dpRadio" checked="true" name="mf" /> 
                </div> 
                <div style="line-height:23px;font-size:11px"><asp:Literal ID="Literal24" runat="server" Text="<%$ Resources: registration, female %>" /></div>  
                <div class="radio" style="margin-left:10px" onmousedown="effect(this)" onmouseup="handle(this)" onmouseout="startClearing()">   
                    <input type="radio" runat="server" id="radMale" value="2" class="dpRadio" name="mf"  /> 
                </div> 
                <div style="line-height:23px;font-size:11px"><asp:Literal ID="Literal25" runat="server" Text="<%$ Resources: registration, male %>" /></div>  
            </div> 
            <div class="block" id="birthDate" runat="server">  
                <div class="text11_707070_Login" ><asp:Literal ID="Literal26" runat="server" Text="<%$ Resources: registration, birthDate %>" /></div>  
                <img style="margin-left:10px;" src="Prometheus/Vista/ComboBox/dropBoxLeftOFF.gif" id="imgselNoBlankBirthYear_Input" /> 
                <telerik:RadComboBox Height="200px" Width="64px" EnableEmbeddedSkins="false" Skin="Vista" ID="selNoBlankBirthYear" OnSelectedIndexChanged="getDaysInMonth" runat="server"></telerik:RadComboBox> 
                <img style="margin-left:10px;" src="Prometheus/Vista/ComboBox/dropBoxLeftOFF.gif" id="imgselNoBlankBirthMonth_Input" /> 
                <telerik:RadComboBox Width="84px" EnableEmbeddedSkins="false" Skin="Vista" ID="selNoBlankBirthMonth" runat="server" OnSelectedIndexChanged="getDaysInMonth"></telerik:RadComboBox> 
                <img style="margin-left:10px;" src="Prometheus/Vista/ComboBox/dropBoxLeftOFF.gif" id="imgselNoBlankBirthDay_Input" /> 
                <telerik:RadComboBox Width="64px" EnableEmbeddedSkins="false" Skin="Vista" ID="selNoBlankBirthDay" runat="server"></telerik:RadComboBox> 
            </div> 
            <div class="block">  
                <div class="text11_707070_Login" ><asp:Literal ID="Literal27" runat="server" Text="<%$ Resources: registration, country %>" /></div>  
                <img style="margin-left:10px;" src="Prometheus/Vista/ComboBox/dropBoxLeftOFF.gif" id="imgselNoBlankCountry_Input" /> 
                <telerik:RadComboBox Width="239px"  EnableEmbeddedSkins="false" OnSelectedIndexChanged="switchStateProvince"  Skin="Vista" ID="selNoBlankCountry" runat="server"></telerik:RadComboBox> 
            </div> 
            <div class="block" id="stateProvince" runat="server">  
                <div class="text11_707070_Login" id="lblStateProvince" runat="server"><asp:Literal ID="Literal28" runat="server" Text="<%$ Resources: registration, state %>" /></div>  
                <img style="margin-left:10px;" src="Prometheus/Vista/ComboBox/dropBoxLeftOFF.gif" id="imgselNoBlankStateProvince_Input"  /> 
                <telerik:RadComboBox Width="239px"  EnableEmbeddedSkins="false"  Skin="Vista" ID="selNoBlankStateProvince" runat="server"></telerik:RadComboBox> 
            </div> 
    <div style="width:inherit;">  
                <div class="checkbox" style="margin:5px 0 0 30px"  onmousedown="effect(this)" onmouseup="handle(this)" onmouseout="startClearing()">  
                    <input type="checkbox" class="dpCheckbox" id="chkNoBlankAgree" runat="server" />   
                </div> 
                <div style="line-height:23px;font-size:11px;margin:5px 0 0 0"><asp:Literal ID="Literal46" runat="server" Text="<%$ Resources: registration, agreeTerms %>" /></div>  
                <div  class="bgDpButton" style="float:right;margin-right:30px" onmousedown="dpButtonMouseDown('btnAcceptLeft','btnAccept','btnAcceptRight')" onmouseup="dpButtonMouseUp('btnAcceptLeft','btnAccept','btnAcceptRight')" onmouseout="dpButtonMouseUp('btnAcceptLeft','btnAccept','btnAcceptRight')">   
                    <img id="btnAcceptLeft" src="images/buttons/btnLeftUp.png" alt="img" /> 
                    <button id="btnAccept"  runat="server" class="dpButton" onserverclick="doRegistration"><asp:Literal ID="Literal8" runat="server" Text="Accept" /></button>  
                    <img id="btnAcceptRight" src="images/buttons/btnRightUp.png" alt="img" /> 
                </div> 
            </div> 
     
    <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">  
        <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="selNoBlankCountry">  
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="code" /> 
                    <telerik:AjaxUpdatedControl ControlID="ccType"  /> 
                    <telerik:AjaxUpdatedControl ControlID="ccNumber" /> 
                    <telerik:AjaxUpdatedControl ControlID="ccDate" /> 
                    <telerik:AjaxUpdatedControl ControlID="txtNoBlankPassword" /> 
                    <telerik:AjaxUpdatedControl ControlID="stateProvince" LoadingPanelID="lp" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
            <telerik:AjaxSetting AjaxControlID="selNoBlankBirthYear">  
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="birthDate" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
            <telerik:AjaxSetting AjaxControlID="selNoBlankBirthMonth">  
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="birthDate" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
            <telerik:AjaxSetting AjaxControlID="selNoBlankCCType">  
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="txtNumNoBlankCCNumber" /> 
                    <telerik:AjaxUpdatedControl ControlID="txtNumNoBlankVerNumber" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
        </AjaxSettings> 
    </telerik:RadAjaxManagerProxy> 

    So the problem is this:
    When i select the radCombobox selNoBlankCountry and select a different item, i loose the data enterd in the password ,confirmPassword, and the radio button selected.

    But the other dropdown work fine!

    If i put the code in the page load of my container page like this:
    if (!IsPostBack)  
                {  
                    //Get the WebUserControl  
                    Control ctlReg = (Control)Page.FindControl("testUserctl");  
                    //Get user control's button and label  
                    HtmlButton MyButton1 = (HtmlButton)ctlReg.FindControl("btnAccept");  
                    RadAjaxManager1.AjaxSettings.AddAjaxSetting(MyButton1, div1);  
                    RadAjaxManager1.AjaxSettings.AddAjaxSetting(MyButton1, div2);  
                } 

    I get to keep the data enterd but the button "btnAccept" is not "ajaxified" and thus cause a postback.

    I cannot figure this one out!
    Thanks!
    Mat
  2. John
    John avatar
    416 posts
    Member since:
    Oct 2006

    Posted 23 Jan 2008 Link to this post

    hi


    Could you try setting EnableAjax="false" for the grid and confirm whether the problem persists (for testing purposes you can temporarily disable the Ajax as well so we can confirm that this problem is not triggered by the ajax requests).


    Thank you...
    <John:Peel />
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top