初始文本未填充在文本框中

时间:2009-09-28 10:43:21

标签: asp.net visual-studio-2008 text textbox pageload

我在asp.net网页的文本框中放了一个初始文本。在文本属性框中。

我想在网页的加载时加载文本。

虽然我调试并运行文本框没有填充该文本。

请帮帮我。

 <td class="textFieldColumn" style="height:16px!important;">
                                                    <asp:TextBox ID="txtUserID" text="Enter User id.." runat="server" AutoPostBack="true" 
                                                        CssClass="text_box_3"></asp:TextBox>
                                                        <asp:RequiredFieldValidator ID="rfvUserID" CssClass="requiredField" runat="server" ControlToValidate="txtUserID"
                                                        ErrorMessage="* Required field" ValidationGroup="Form2"></asp:RequiredFieldValidator><div class="smallText" nowrap>
                                                        &nbsp;&nbsp;(This would be the ID you would normally log on with.)</div></td>




  Private Sub mvRequestorForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles mvRequestorForm.Load
        txtUserID.Text = "Enter User ID..."
    End Sub













<input name="txtUserID" type="text" onchange="javascript:setTimeout('__doPostBack(\'txtUserID\',\'\')', 0)" onkeypress="if (WebForm_TextBoxKeyHandler(event) == false) return false;" id="txtUserID" class="text_box_3" />

RENDERED CODE

1 个答案:

答案 0 :(得分:0)

我会使用AJAX TextBoxWatermark

http://www.asp.net/AJAX/AjaxControlToolkit/Samples/TextBoxWatermark/TextBoxWatermark.aspx

<ajaxToolkit:TextBoxWatermarkExtender ID="txtExtender1" runat="server"
    TargetControlID="txt"
    WatermarkText="Type First Name Here"
    WatermarkCssClass="watermarked" />
<asp:Textbox id="txt" ruant="server" />