I'm using inline C# to write a dynamic drop down. Depending on if the user is logged in or not. I'd like to be able to write in some asp textbox's (see below). Is there a way to do this, or a better way of accomplishing the task.
Thanks.
<%
if (checkLogin() == true)
{
Response.Write("<ul id=\"userDropdown\">");
Response.Write("<li class=\"userDropdown_right\"><a href=\"#\" class=\"drop\">Test User</a>");
Response.Write("<div class=\"dropdown align_right\" style=\"width:175px;\">");
Response.Write("<div class=\"col_2\">");
Response.Write("<h2>Test User</h2>");
Response.Write("<h3>Administrator</h3>");
Response.Write("<a href=\"#\">Settings </a>");
Response.Write("<a href=\"#\">Logout </a>");
Response.Write("</div></div></li></ul>");
}
else
{
Response.Write("<ul id=\"userDropdown\">");
Response.Write("<li class=\"userDropdown_right\"><a href=\"#\" class=\"drop\">Login</a>");
Response.Write("<div class=\"dropdown align_right\" style=\"width:175px;\">");
Response.Write("<div class=\"col_2\">");
**<asp:TextBox ID="test" runat="server" />**
Response.Write("</div></div></li></ul>");
}
%>
PlaceHoldercontrol to direct the output to a specific place on the page rather thanResponse.Write. Also, no, writing a server-side control to the page in this manner will not work (at least, it shouldn't, and if it does you shouldn't trust it). I'll defer to the other suggestions already given for a better approach...