Search code examples
c#asp.nettextbox

How to assign dynamic placeholder to Textbox?


I know this question is asked before for assigning text to textbox, but they didn't have answers or the given answers didn't work for me. I have a static function for translations and I'm trying to use that to assign a placeholder to a Textbox. How can I do it in aspx page?

My code is:

    <asp:TextBox ID="search" runat="server" 
    placeholder='<%# islem.DilGetir(7) %>'>
    </asp:TextBox>

This one returns this sourcecode:

<input name="ctl00$search" type="text" id="ctl00_search">

Solution

  • you can use ajax controll toolkit text box watermark I find it to be mnost usefull in aspx apps

    http://www.asp.net/AjaxLibrary/AjaxControlToolkitSampleSite/TextBoxWatermark/TextBoxWatermark.aspx

     <asp:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender1" runat="server" TargetControlID ="search" WatermarkText="textthe my name" WatermarkCssClass="watermarked">
            </asp:TextBoxWatermarkExtender>
    

    on the back end

    TextBoxWatermarkExtender1.WatermarkTex=islem.DilGetir(7);