Click here to Skip to main content
14,217,056 members
Rate this:
Please Sign up or sign in to vote.
I want set CSS style attributes of some controls (like input text) just by
Request.Form["x"]
method in aspx page .cs code ,runat="server" is set for that controls and them is known in intellisense of .cs and them didn't find by
form1.FindControl("x")
and convert them to
HtmlInputText
for some my reason but i want set their CSS style in another syntax.
Thanks for any suggestion

What I have tried:

HtmlInputText intex = FindControl("txtrelat0") as HtmlInputText;
string text=Request.Form["txtrelat0"].ToString();
Posted
Updated 27-Mar-16 20:16pm

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Add the controls in an asp panel

<asp:Panel ID="panel1" runat="server">
     <asp:TextBox runat="server" ID="txt1" />
     <input type="text" runat="server" id="txt2" />
 </asp:Panel>


find the control and cast it
var txt1 = panel1.FindControl("txt1") as TextBox;  // asp textbox
          txt1.Style.Add("background-color", "orange");

          var txt2 = panel1.FindControl("txt2") as HtmlInputText;  // input type = text
          txt2.Style.Add("background-color", "blue");
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100