Имеется asp.net форма (vb.net). В code-behind ничего не добавляется. Вся динамика на клиенте через JQuery.
Добавляю «невинную» строчку:
<input id="txt_BranchName" name="txt_BranchName" class="HebrewInputRTL jLimit25 row_BranchName" type="text" runat="server" />
и после сабмита получаю:
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
Весь код страницы:
<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>
Конечно, стоит убрать инпут и все сабмитится.
Всякие stackoverflow рассказывают как правильно динамически добавлять контролы. Но у меня все статическое.