2012-07-09 32 views
1

我想用asp.net和jquery創建水印。我有一個文本框的網頁是這樣的:使用jQuery和asp.net創建水印

<tr> 
     <td> 
      <%=GetLocaleResourceString("Address.FirstName")%>: 
     </td> 
     <td> 
      <nopCommerce:SimpleTextBox runat="server" ID="txtFirstName" Width="165px" class="watermark" Text="Type your First Name" 
    Tooltip="Type your First Name" ErrorMessage="<% $NopResources:Address.FirstNameIsRequired %>"> 
      </nopCommerce:SimpleTextBox> 
      <asp:Label ID="lblShippingAddressId" runat="server" Visible="false"></asp:Label> 
     </td> 
    </tr> 
    <tr> 
     <td> 
      <%=GetLocaleResourceString("Address.LastName")%>: 
     </td> 
     <td> 
      <nopCommerce:SimpleTextBox runat="server" ID="txtLastName" Width="165px" ErrorMessage="<% $NopResources:Address.LastNameIsRequired %>"> 
      </nopCommerce:SimpleTextBox> 
     </td> 
    </tr> 

其中nopCommerce:SimpleTextBox是這樣的用戶控件:

<%@ Control Language="C#" AutoEventWireup="true" 
    Inherits="NopSolutions.NopCommerce.Web.Modules.SimpleTextBox" Codebehind="SimpleTextBox.ascx.cs" %> 
<asp:TextBox ID="txtValue" runat="server"></asp:TextBox> 
<asp:RequiredFieldValidator ID="rfvValue" ControlToValidate="txtValue" Font-Name="verdana" 
    Font-Size="9pt" runat="server" Display="Dynamic">*</asp:RequiredFieldValidator> 

我下面這篇文章:

http://weblogs.asp.net/dotnetstories/archive/2011/11/24/creating-a-simple-watermark-effect-using-jquery.aspx

和在使用文本框控件的頁面中添加css類和標題(請參閱第一個標記中的標題和css)。

,但是當我看到網頁源我得到這個標記:

<input type="text" style="width:165px;" class="textBox" id="ctl00_ctl00_cph1_cph1_ctrlCheckoutSinglePage_ctrlCheckoutBillingAddress_ctrlBillingAddress_txtEmail_txtValue" name="ctl00$ctl00$cph1$cph1$ctrlCheckoutSinglePage$ctrlCheckoutBillingAddress$ctrlBillingAddress$txtEmail$txtValue"> 

無CSS沒有標題添加。請建議我如何添加水印?

問候, 阿西夫·哈米德

回答

0

看來你不應用class="watermark"txtValue

<asp:TextBox ID="txtValue" runat="server"></asp:TextBox> 

應該

<asp:TextBox ID="txtValue" class="watermark" runat="server"></asp:TextBox> 
+0

我申請它的頁面,這個文本框控件正在但是當頁面呈現時,class =「textBox」被添加。 – DotnetSparrow 2012-07-09 15:04:46