Click here to Skip to main content
15,879,096 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want set CSS style attributes of some controls (like input text) just by
C#
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
C#
form1.FindControl("x")
and convert them to
C#
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

Add the controls in an asp panel

ASP.NET
<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
C#
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");
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900