None
None

Reputation: 5670

unable to set value from server-side to a Textbox in client side

My code is like this

 <asp:TextBox type="text" name="txtEndDate" Text="<%#library.GetDictionaryItem("ProfilePages_CVR nummer")%>"  runat="server"></asp:TextBox>

Everything looks okay to me, But i don't know why its throwing an error

The server tag is not well formed.

Upvotes: 0

Views: 152

Answers (2)

Dmitriy Khaykin
Dmitriy Khaykin

Reputation: 5258

The issue is that because of the ASP.net brackets which contain double quotes inside them

<asp:TextBox Text="<%# someMethod("someValue") %>" />

inside the Text field, you need to use single quotes instead of double quotes on that property, like this:

<asp:TextBox type="text" name="txtEndDate" 
    Text='<%# library.GetDictionaryItem("ProfilePages_CVR nummer")%>'  
    runat="server">
</asp:TextBox>

And it will work.

Note also that you are using the DataBinding notation ( <%# ) which will only work if your TextBox is inside a DataBound control, or you call DataBind on the control or page containing this TextBox.

Upvotes: 1

Girish Vadhel
Girish Vadhel

Reputation: 745

Use single quotes like:

<asp:TextBox type="text" name="txtEndDate" Text='<%#library.GetDictionaryItem("ProfilePages_CVR nummer")%>'  runat="server"></asp:TextBox>

Upvotes: 2

Related Questions