Sign in to follow this  

[web] accessing to asp components from C# file

This topic is 4379 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello. In my aspx file, I have : <FooterTemplate> <asp:TextBox Runat="server" ID="txtBoxGenre" TextMode='<%# DataBinder.Eval(Container, "DataItem.genre") %>'> </asp:TextBox> </FooterTemplate> How can I get text from this text box from C# file that is a background code of this aspx file. Thanks in advance

Share this post


Link to post
Share on other sites
The txtBoxGenre.Text or txtBoxGenre.Value property will be whatever text is in the textbox. Hope that helps.

-AJ

Share this post


Link to post
Share on other sites
Quote:
Original post by u235
The txtBoxGenre.Text or txtBoxGenre.Value property will be whatever text is in the textbox. Hope that helps.

-AJ


But from C# file I cannot do "this.txtBoxGenre". C# file cannot directly access to <asp:xxx...> components that belong to aspx file.The solution is that I have to somehow do (TextBox) casting to EventArgs variable. Someone told me that this must be done from within DataGrid_CommandItem function or something like that. Does this sound familiar to you ?

Share this post


Link to post
Share on other sites
Quote:
Original post by cpp_boy
Quote:
Original post by u235
The txtBoxGenre.Text or txtBoxGenre.Value property will be whatever text is in the textbox. Hope that helps.

-AJ


But from C# file I cannot do "this.txtBoxGenre". C# file cannot directly access to <asp:xxx...> components that belong to aspx file.The solution is that I have to somehow do (TextBox) casting to EventArgs variable. Someone told me that this must be done from within DataGrid_CommandItem function or something like that. Does this sound familiar to you ?


You should be able to and I don't see what it wouldn't work. I've only done ASP.NET web programming with VB.NET and I have done things like that simply by using something like myTextBox.Text to retrieve the contents of the textbox. And since they are both .NET langauges, you should be able to do the same thing in C#. Give it a try and see what happens.

-AJ

P.S. The last three sentences...no this doesn't sound familiar to me...correction, yes it does, but not in this context. DataGrid_CommandItem sounds like something to do with databases.

Share this post


Link to post
Share on other sites
Sign in to follow this