List Info

Thread: How to get HTML presentation of WebControl at the server side?




How to get HTML presentation of WebControl at the server side?
user name
2006-06-22 14:23:42
While page is rendered server-side control <asp:TextBox
id="TextBox1"
runat="server"></asp:TextBox> is
converted to <input name="TextBox1"
type="text" id="TextBox1" />.

Is there any way to get HTML presentation of WebControl or
UserControl
at the server side?

I'll try RenderControl method:
...
StringBuilder sb = new StringBuilder();
TextBox1.RenderControl(new HtmlTextWriter(new
StringWriter(sb)));
string res = sb.ToString();
....
But it always throws the exception "Control
'TextBox1' of type
'TextBox' must be placed inside a form tag with
runat=server."


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "C# Developers" group.
To post to this group, send email to CSDevelopersgooglegroups.com
To unsubscribe from this group, send email to
CSDevelopers-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/CSDevelopers
-~----------~----~----~----~------~----~------~--~---

How to get HTML presentation of WebControl at the server side?
user name
2006-06-22 14:47:18

I just got that exception as well and fixed it with <FORM runat-server> code </FORM&gt;

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "C# Developers" group.
To post to this group, send email to CSDevelopersgooglegroups.com
To unsubscribe from this group, send email to CSDevelopers-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/CSDevelopers
-~----------~----~----~----~------~----~------~--~---

How to get HTML presentation of WebControl at the server side?
user name
2006-06-23 06:26:57

Jon Yarberry написав:
> I just got that exception as well and fixed it with
<FORM
> runat-server> code</FORM>
>
> ------=_Part_6423_9164637.1150987638679
> Content-Type: text/html; charset=ISO-8859-1
> X-Google-AttachSize: 147
>
> <br>I just got that exception as well and fixed
it with &lt;FORM runat-server&gt; <span
style="font-style: italic;">code</span>
&lt;/FORM&gt;<br>
>
> ------=_Part_6423_9164637.1150987638679--

Thanks for reply, Jon

In fact, the textbox is placed inside of the form tag with
runat=server, but when I call RenderControl method of single
control
separately from whole page rendering, it rises the
exception.
Example:

cs:
private void Page_Load(object sender, System.EventArgs e)
{
  System.Text.StringBuilder sb = new
System.Text.StringBuilder();
  TextBox1.RenderControl(new HtmlTextWriter(new
System.IO.StringWriter(sb)));
  string res = sb.ToString();
}

aspx:
<body MS_POSITIONING="GridLayout">
  <form id="Form1" method="post"
runat="server">
    <asp:TextBox id="TextBox1"
runat="server"></asp:TextBox>
  </form>
</body>

But maybe I'm going the wrong way.
All I need is HTML presentation of Control at the server
side.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "C# Developers" group.
To post to this group, send email to CSDevelopersgooglegroups.com
To unsubscribe from this group, send email to
CSDevelopers-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/CSDevelopers
-~----------~----~----~----~------~----~------~--~---

How to get HTML presentation of WebControl at the server side?
user name
2006-06-23 13:59:43

I'm sorry that it didn't help. :/ The only other thing I can thinkof is if you're using .NET is under design view is to right click and make sure that 'Run As Server Control' is selected, but I don't think that is the problem.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "C# Developers" group.
To post to this group, send email to CSDevelopersgooglegroups.com
To unsubscribe from this group, send email to CSDevelopers-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/CSDevelopers
-~----------~----~----~----~------~----~------~--~---

[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )