user1046355
user1046355

Reputation:

Setting the value of a Html textbox from the Asp.Net codebehind

I'm trying to set a value from the database into a Html component, the code is as follow:

<asp:RadioButtonList ID="rbFiltroCostesPre" runat="server" AutoPostBack="false" Width="286px">
   <asp:ListItem Selected="True" Value="A">All</asp:ListItem>
   <asp:ListItem Value="Greater">First 10</asp:ListItem>
   <asp:ListItem Value="GreaterThan">Greater than: &lt;input ID=&quottxtGreaterThan&quot; type=&quot;text&quot; &gt;</asp:ListItem>                                              
</asp:RadioButtonList>   

The last ListItem has a Html tag inside, like:

<input id="txtGreaterThan" type="text"/>   

, which has been transform by the Visual Web Development IDE.

Can I set it's value dynamically from the codebehind? Thx.

Upvotes: 0

Views: 761

Answers (1)

CAbbott
CAbbott

Reputation: 8098

Sorry, but you can't do that with the managed ListItem control. What's happening in your page is it's setting the Text value of your ListItem with Greater than: &lt;input ID=&quottxtGreaterThan&quot; type=&quot;text&quot; &gt;.

What you could do is to use a RadioButton instead of a RadioButtonList and place a TextBox control next to the RadioButton. This would allow you to access it server-side.

Upvotes: 1

Related Questions