Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C# controls

Status
Not open for further replies.

seabaz2000

IS-IT--Management
Feb 24, 2006
79
IE
Hi
Just wondering if its possible to write asp code in c# i.e. as follows.
Code:
tblCell1.Controls.Add(new LiteralControl("<a href=\"javascript:OpenPopupPage('Calendar.aspx','<%=DateTextBox.ClientID %>','<%= Page.IsPostBack %>');\">\n"));
Because when I run it it doesn't compile server side, it only compiles client side.
Regards
 
This is code in your code behind then so you wouldn't use ASP code in it.

Code:
tblCell1.Controls.Add(new LiteralControl("<a href=\"javascript:OpenPopupPage('Calendar.aspx','<%=DateTextBox.ClientID %>','" + Page.IsPostBack + "');\">\n"));
 
Thanks tperri for your response. I would just like to ask you a question about webparts. When I use webparts on a portal I am building. I create the webpart in a c# file and then call it through a single line of asp code. So to use any of the asp objects I have to pass them in as controls. My question is, is there any way of passing in the asp code and not the controls. e.g. instead of
Code:
txtBox = new TextBox();.....
tableCell1.Controls.Add(txtBox);
using something like
Code:
tableCell1.something.Add(<asp:TextBox ID="txtBox"....);
This code will then be compiled server side but written in the c# that lies behind.
Regards
 
Why do you want to do it that way? Just curious.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top