W
W
wintermute2011-05-08 16:45:43
ASP.NET
wintermute, 2011-05-08 16:45:43

Adding contorla (input:text) results in an exception during post

There is an asp.net form (vb.net). Nothing is added to the code-behind. All dynamics on the client through JQuery.
I add an "innocent" line:

<input id="txt_BranchName" name="txt_BranchName" class="HebrewInputRTL jLimit25 row_BranchName" type="text" runat="server" />


and after submit I get:

Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. bla bla bla

Whole code of the page:
<body>
    <div id="div_Body" dir="rtl" class="BodyDiv" style="direction:ltr">
        <form id="frm_NG_03630" runat="server" method="post" class="RequestForm" style="direction:rtl; width:auto; height:auto; position:absolute" >
                    
            <div id="tbl_MainLayout" dir="rtl" style="vertical-align:top" >
                <br />
                <div class="eoTabStylePopup PropertiesBlock">
                    <label class="PropertiesBlockLabel">זיהוי לקוח</label>
                    <br />
                    <span style="width:20px"></span>
                    <label class="LabelDiv IDLabel">   לקוח:</label>
                    <input id="Importer" dir="ltr" onkeydown="Importer_onKeyDown(this, 'txt_externalID_fromCRM', 'txt_ImporterName')" type="text" name="Importer" runat="server" />
                    <img class="glassOE" alt="glassOE" style="VERTICAL-ALIGN: bottom" src="/FlyingCargo/NetCommon/Images/glassOE.gif" />
                    <input id="txt_ImporterName" class="FullCodeInput" name="txt_ImporterName" type="text" runat="server" disabled="true" />
                    <input style="display:none !important" id="txt_externalID_fromCRM" class="FullCodeInput" name="txt_externalID_fromCRM" type="text" runat="server" />
                    <br />
                    <input type="radio" id="radio_customerIdentificationByExternalID" name="identificationType" value="2" runat="server" checked="true" />
                    <label class="LabelDiv IDLabel">   ת"ז/ח"פ:</label>
                    <input type="text" id="txt_externalId" name="txt_externalId" runat="server" class="jLimit9 LatinInputLTR" />
                    <br />
                    <input type="radio" id="radio_customerIdentificationByPassport" name="identificationType" value="3" runat="server" />
                    <label class="LabelDiv IDLabel">   דרכון:</label>
                    <input type="text" id="txt_passportNumber" name="txt_passportNumber" runat="server" class="LatinInputLTR jLimit15" />
                    <input id="drpOriginCountry" type="text" name="drpOriginCountry" class="dropdownBorder LatinInputLTR" onmousedown="MouseDown_ACTB(this)" onkeydown="drpOriginCountry_onkeydown(this)" combovalue="" value="" tag="OriginCountry|string|" runat="server" />
                    <input type="text" id="txt_PassportStateCode" name="txt_PassportStateCode" runat="server" class="CodeInput" />
                    <input id="radioDarkonType_Darkon" type="radio" name="group_SugDarkon" value="01" checked="true" runat="server" >דרכון</input>
                    <input id="radioDarkonType_Maavar" type="radio" name="group_SugDarkon" value="02" runat="server" >תעודת מעבר</input>                                        
                    
                </div>   
                
                <div class="TableSpacerDiv_5"></div>
                <div class="eoTabStylePopup PropertiesBlock">
                    <label class="PropertiesBlockLabel" id="lbl_oldAddressContactPhoneID">פרטים קודמים</label>
                    <br class="oldAddressContactPhoneID HiddenByDefault" />
                    <label class="LabelDiv_Bold oldAddressContactPhoneID HiddenByDefault">   זיהוי כתובת קודמת:</label>
                    <input class="HebrewInputRTL jLimit15 oldAddressContactPhoneID HiddenByDefault" type="text" id="txt_OldAddressID" name="txt_OldAddressID" runat="server" />
                    <div class="TableSpacerDiv_5"></div>
                </div>
                
                <div class="TableSpacerDiv_5"></div>                
                <div class="eoTabStylePopup PropertiesBlock">
                    <label class="PropertiesBlockLabel">תקשורת</label>
                    <br />
                    
                    <label class="LabelDiv_5 MandatorySign">   טלפון:</label>
                    <input id="txt_CommunicationAddress_TE" name="txt_CommunicationAddress_TE" runat="server" class="LatinInputLTR jLimit50" />
                    <input type="text" id="txt_CommunicationAddress_TE_Code" name="txt_CommunicationAddress_TE_Code" class="LatinInputLTR HiddenCodeInput" value="TE" runat="server"></input>
        
                    <label class="LabelDiv_Bold">   טלפון סלולרי:  </label>
                    <input id="txt_CommunicationAddress_AL" name="txt_CommunicationAddress_AL" class="LatinInputLTR jLimit50" runat="server" />
                    <input type="text" id="txt_CommunicationAddress_AL_Code" name="txt_CommunicationAddress_AL_Code" class="LatinInputLTR HiddenCodeInput" value="AL" runat="server" />
                    
                    <label class="LabelDiv_Bold">   דוא"ל:</label>
                    <input type="text" id="txt_CommunicationAddress_EM" name="txt_CommunicationAddress_EM" class="LatinInputLTR jLimit50" runat="server" />
                    <input type="text" id="txt_CommunicationAddress_EM_Code" name="txt_CommunicationAddress_EM_Code" class="LatinInputLTR HiddenCodeInput" value="EM" runat="server" />
                    
                    <br /><div class="TableSpacerDiv_1"></div>
        
                    <label class="LabelDiv_5">   פקס:</label>
                    <input type="text" id="txt_CommunicationAddress_FX" name="txt_CommunicationAddress_FX" class="LatinInputLTR jLimit50" runat="server" />
                    <input  type="text" id="txt_CommunicationAddress_FX_Code" name="txt_CommunicationAddress_FX_Code" class="LatinInputLTR HiddenCodeInput" value="FX" runat="server" />
        
                    <label class="LabelDiv_Bold">   אתר אינטרנט:</label>
                    <input type="text" id="txt_CommunicationAddress_AH" name="txt_CommunicationAddress_AH" class="LatinInputLTR jLimit50" runat="server" />
                    <input type="text" id="txt_CommunicationAddress_AH_Code" name="txt_CommunicationAddress_AH_Code" class="LatinInputLTR HiddenCodeInput" value="AH" runat="server" />
                    <div class="TableSpacerDiv_5"></div>  
                </div>
                
                
                <div class="TableSpacerDiv_5"></div>
                <div class="eoTabStylePopup PropertiesBlock">
                    <label class="PropertiesBlockLabel">פרטי כתובת</label>
                <br />
                <label class="LabelDiv_6 MandatorySign">   סוג כתובת:</label>
                <input id="drp_AddressType" type="text" name="drp_AddressType" class="dropdownBorder LatinInputLTR"
                    onmousedown="MouseDown_ACTB(this)" onkeydown="drp_AddressType_onkeydown(this)"
                    combovalue="" value="עסק" tag="OriginCountry|string|" runat="server"/>
                    
                <input type="text" name="txt_AddressType" id="txt_AddressType" class="HiddenCodeInput" runat="server" value="1" />
                                                
                <label class="LabelDiv_Bold MandatorySign">   מטרת כתובת:</label>
                <input type="text" name="drp_AddressPurpose" class="dropdownBorder" dir="ltr" onmousedown="MouseDown_ACTB(this)"
                    id="drp_AddressPurpose" onkeydown="drp_AddressPurpose_onkeydown(this)" combovalue=""
                    value="חזקה משפטית" tag="OriginCountry|string|" runat="server" />
                <input type="text" class="HiddenCodeInput" id="txt_AddressPurpose" name="txt_AddressPurpose" runat="server" value="01" />
                                                
                <label class="LabelDiv_Bold MandatorySign">   כתובת בעברית:</label>
                <input type="checkbox" id="checkbox_isHebrewAddress" name="checkbox_isHebrewAddress" runat="server" checked="checked"/>
                    
                <label class="LabelDiv_Bold MandatorySign">   ברש"פ:</label>
                <input type="checkbox" id="checkbox_isPalestinianCity" name="checkbox_isPalestinianCity" runat="server" class="ShortTextInput" />
                
                <br /><div class="TableSpacerDiv_1"></div>
                
                <label class="LabelDiv_6 row_BranchName">   שם סניף:</label>
                
<b>		            <input id="txt_BranchName" name="txt_BranchName" class="HebrewInputRTL jLimit25 row_BranchName" type="text" runat="server" /></b>
                  
                </div>
            </div>
            
            <div class="TableSpacerDiv_5"></div>
            <div class="eoTabStylePopup PropertiesBlock" id="div_SearchButtons">
                <div style="float:left">
                    <div style="float:left; width: 75px;"><wc1:FCButton ID="btn_Search" ButtonText="שלח" runat="server" Button2Lines="False" ButtonSize="Size_67x21"></wc1:FCButton></div>
                    <div style="float:left; width: 75px;"><wc1:FCButton ID="btn_Clear" ButtonText="נקה" runat="server" Button2Lines="False" ButtonSize="Size_67x21"></wc1:FCButton></div>
                    <div style="float:left; width: 75px;"><wc1:FCButton ID="btn_View" ButtonText="צפה" runat="server" Button2Lines="False" ButtonSize="Size_67x21"></wc1:FCButton></div>
                </div>
            </div>
            
            <div class="TableSpacerDiv_5"></div>
            <div class="Err_Text_Table HiddenByDefault eoTabStylePopup PropertiesBlock">
                <div id="ErrorMsg" style="float:left"></div>
            </div>
            
            
        </form>
    </div><!-- /div_Body -->
</body>


Of course, it is worth removing the input and everything is submitted.
Any stackoverflow tell how to dynamically add controls. But everything is static.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Keith, 2011-05-08
@tenbits

Why are you adding the runat='server' attribute? Do this:
JavaScript:

 $("<intput>").attr({'name':'tbSomeName', 'type':'text'}).val('Some Value').appendTo('form')

On Postback:
var value = Request.Params.Get('tbSomeName'); 

W
wintermute, 2011-05-11
@wintermute

Thank you all for your help. Problem control added masterpage

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question