2013-05-08 78 views
1

我正在使用以下下拉框&將其值映射到文本框中。禁用的文本框值單擊按鈕時會丟失

<asp:DropDownList ID="ddlCntry" runat="server" Height="24px" Width="160px" 
     OnChange="Country();"> 
     <asp:ListItem>Select Country</asp:ListItem> 
     <asp:ListItem>India</asp:ListItem> 
     <asp:ListItem>USA</asp:ListItem> 
     <asp:ListItem>UK</asp:ListItem> 
</asp:DropDownList> 


<asp:TextBox ID="TxtCntryRisk" runat="server" 
     ontextchanged="TxtCntryRisk_TextChanged" Width="153px" 
     EnableTheming="True" Enabled="False"></asp:TextBox> 

我有一個計算按鈕,當我點擊按鈕時,我的映射文本框值會丟失。 我希望我的文本框被禁用,以便其值無法更改。 我試過用Readonly=true屬性也是徒勞。會話中,viewstate也不起作用。

但是,當我啓用文本框,它工作正常,沒有損失的價值。 任何幫助? thanx提前。 :-)

回答

0

設置ReadOnly屬性服務器端:

TxtCntryRisk.Attributes.Add("readonly","readonly"); 
+0

再次卡住了。 上面的代碼正在工作,但點擊按鈕後。 在此之前,我可以更改文本框的值。 – Rooney 2013-05-10 10:21:29