protected override void Render(HtmlTextWriter output)
{
variable_with_higher_scope = output;
}
and assign the HtmlTextWriter passed in as a parameter to a higher scope variable instead of instantiating a HtmlTextWriter object? My other question is how can I write html to a specific location on my site here is an example of what i mean
<html>
<head><title></title></head>
<body>
<table id="myTable" runat="Server" width="220" heigth="200">
<tr>
Write text here from visual studio integerated environment (.vb file)
</tr>
</table>
</body>
</html
is there any way of doing that in my vb file using the HtmlTextWriter object and writing in that specific table?
Thanks Guys
Bob.You can't. You need a placeholder for your control to write at that specific location...
1. IMHO it is not a good idea. ASP.NET uses the same HtmlTextWriter to sequentially render the whole page. If you grab it and use not from designated event, you can get unexpected result.
2. The best way to do it is to add some sort of control in desired place (for instance literal control). Then you can access controls properties/content from .vb as you like.
You can do it also by binding to function/property in codebehind:
<html>
<head><title></title></head>
<body>
<table id="myTable" runat="Server" width="220" heigth="200">
<tr>
<%# SomeFunctionInVBFile %></tr>
</table>
</body>
</html>
Don't forget to call DataBind method of page to execute <%# statements.
Hi llangleyben,
I am new to asp.net could you explain what you mean by a instance literal control by giving some examples? Thanks for your help,
Bob
Drag Literal control from toolbox (Web Forms tab) to desired place on your form. Set its text in codebehind.
HTML:
<asp:Literal id="Literal1" runat="server"></asp:Literal>
Codebehind:
this.Literal1.Text = "text from visual studio integerated... "
Hi llangleyben
Or how ever can answer this, I created a htmlcontrol a table and gave it an id and runat server attribute so I could refer to it in my code. I then created a StringBuilder and append how the table should be structured. I finally assigned my string builder to the htmlcontrol InnerHtml attribute so that the table could be dynamically created at page load. But I got an error when loading the page here is the error "The 'mode' attribute is case sensitive and must be one of the following values: On, Off, RemoteOnly." the funny thing is that when i comment out one line of code the one that assigns the InnerHtml attribute to a string the page is displayed with no errors. Could you let me know what I have done wrong?
Thanks Bob.
0 comments:
Post a Comment