I have a code for input i want to get the value of Literal Control dynamically. How do i get the value of input I have selected?
Front Code
<ul id="ulTest" runat="server"></ul>
Dim a As LiteralControl = New LiteralControl("<input type = ""date"" id=""start"" name=""trip-start"" value = ""2018-07-22"" min = ""2018-01-01"" max=""2018-12-31"">")
a.ID = "as"
ulTest.Controls.Add(a)
Dim tb As TextBox = (TextBox)a.FindControl("as")
ul1.Controls.Add(New LiteralControl(a.Text))
A literal control represents client-side markup that gets rendered out, and should have no expectation of being able to process posted data. If you are writing a literal out that is a textbox, you can add that as a literal, but the only way to read the value from it is to use:
Request.Form("trip-start")
There will be no direct control representation other than to do:
foreach (var ctl in ulText.Controls)
{
if (ctl is LiteralControl)
{
var a = (LiteralControl)ct;
//Attempt to do something
}
}
I don't believe that the value you entered will be posted back; it simply will be the original markup declaration. Also, you can't cast this then as a textbox; an error will occur:
var tb = (TextBox)a.FindControl("as"); //Throws Exception
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.