I have an aspx page and added a literal control:
<asp:Literal runat="server" ID="ControlLiteral"></asp:Literal>
Then, in codebehind I'm using a for sentence to massively create controls, the idea is something like this:
ControlLiteral.Text = @"<input id=""txtMaterial1"" type=""text"" value=""escribe un valor"" disabled=""disabled"" onclick=""somefunction(this)"" style=""width:250px;"" />
then I want to get the value after a submit button in codebehind, but problem is I can't find them and I'm starting to think that codebehind is not aware of those controls even though I check the HTML source code and everything is there so... any ideas?
I have tried the following:
added the runat="server" in the string that creates the control, but of course, it doesn't work, it just added that text runat="server" in the html
Request.Form["txtMaterial"] or Request["txtMaterial"] finds nothing
Page.Controls.Find("txtMaterial") returns null
When I do this, this.from1.Controls.Count it retrieves only 11 controls isntead of the 210 controls I added in the for statement, and if retrieve them like this this.from1.Controls[2], those irrelevant html tags created by the asp.net engine
Page.Controls.Count retrieves only 5 controls
Those controls are inside a table, dont know it that has something to do, so, do you have any ideas, it's been a while since the last time I used asp.net but remember that this was possible, please let my know your ideas,
Try using
submit
to call a function in the javascript.example:
codebehind page_load: