views:

218

answers:

3

I have a text box where there is a initial text has been set in the text box of asp.net website.

But after rendering the web page the text box is not showing initial text in the text box.

Code for text box

<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>
  (This would be the ID you would normally log on with.)
 </div>
</td>

Code for Load page:

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

Code after rendering :

<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" />
A: 

Have you made sure that the mvRequestorForm_Load event fires?

Also code after rendering is missing: FIXED.

Are you using AJAX?

Why have you set the txtbox to AutoPostback?

callisto
A: 

I notice your "Code for Load Page" section references the load event of mvRequestorForm. Is this a multiview? Perhaps something fishy is going on here. Try to update this to handle the actual page load event (via Me.Load) as outlined in the sub below.

 Protected Sub mvRequestorForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        txtUserID.Text = "Enter User ID..."
    End Sub
Jakkwylde
A: 

Am not sure, but your default text might be in the wrong place. When I use the properties window to set the text value for and asp textbox control, it places the text in between the opening and closing tags for the asp control. In your case, it would look like this:

<asp:TextBox ID="txtUserID" runat="server" AutoPostBack="true" CssClass="text_box_3">Enter User id..</asp:TextBox>

Then in the browser it will place that text in the input's value attribut, spitting out code something like this:

<input name="txtUserID" type="text" value="Enter User id.." class="text_box_3" etc...
JennC