我正在爲我的網站做一個驗證碼,沒有什麼特別的和個人使用。我的問題是,當我點擊刷新按鈕在驗證碼框中顯示一個新圖像時,它也應該重置驗證碼文本框。按鈕刷新不清除文本
我設置它像這樣
protected void btnRefresh_Click(object sender, EventArgs e)
{
//This is the call that creates a new image
FillCaptcha();
// to clear the text box
txtCaptcha.Text = String.Empty;
}
當我運行它顯示在文本框中輸入的值的調試器和後,當其設置爲「」。
這裏是按鈕和文本框的佈局有一段時間了堆棧
<asp:TableRow>
<asp:TableCell>
Enter Below Captcha Code :
</asp:TableCell>
<asp:TableCell>
<asp:TextBox ID="txtCaptcha" runat="server" Width="200px"></asp:TextBox>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
</asp:TableCell>
<asp:TableCell VerticalAlign="middle">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UP1" runat="server">
<ContentTemplate>
<table>
<tr>
<td style="height: 50px; width:120px; border:solid; border-color:blue; text-align:center;">
<asp:Image ID="imgCaptcha" runat="server" />
</td>
<td valign="middle">
<asp:Button ID="btnRefresh" runat="server" Text="Refresh" OnClick="btnRefresh_Click" />
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</asp:TableCell>
</asp:TableRow> `
伊夫搜索和每個人似乎都將其設置爲我擁有它。我在另一個函數中調用了txtCaptcha.Text = String.Empty;
,它工作正常。任何幫助將不勝感激。如果我對事物不清楚,請讓我知道並且盡我所能來更好地解釋它。
'txtCaptcha.Text'是在UpdatePanel外面。把它移進去。 – VDWWD
你確定'txtCaptcha.Text = String.Empty;'行被擊中? –
@VDWWD現在嘗試。 – poohbear