Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > custom webcontrol : render and then get "html" result in server side

Reply
Thread Tools

custom webcontrol : render and then get "html" result in server side

 
 
rabii
Guest
Posts: n/a
 
      05-04-2005
Hello,
Is there any way to render/execute my custom webcontrol in server side
then get the result (html) into string ?
 
Reply With Quote
 
 
 
 
Matteo Migliore
Guest
Posts: n/a
 
      05-04-2005
Hello.

> Hello,
> Is there any way to render/execute my custom webcontrol in server side
> then get the result (html) into string ?


Yes, you can use this sample:
--------------------------
Button Button1 = new Button();
Button1.Text = "Click";
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter tw = new HtmlTextWriter(sw);
Button1.RenderControl(tw);
string ret = t.ToString();
sw.Close();
tw.Close();
--------------------------

Replace Button class with yours and
the game is up!

Matteo Migliore.


 
Reply With Quote
 
 
 
 
rabii
Guest
Posts: n/a
 
      05-04-2005
Thanks men, that's what I'm looking for .

may be :
string ret = sw.ToString(); not t.ToString()

 
Reply With Quote
 
rabii
Guest
Posts: n/a
 
      05-11-2005
Now I have the problem with UserControl. It dosn't generate html code
(no error was shown but the result is empty).

 
Reply With Quote
 
Matteo Migliore
Guest
Posts: n/a
 
      06-29-2005
Excuse me for my little delay .

> Now I have the problem with UserControl. It dosn't generate html code
> (no error was shown but the result is empty).


You can obtain HTML code from a UserControl
using the function LoadControl to instantiate the object.

Than is the same thing.

Bye,
Matteo Migliore.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom webcontrol that references another webcontrol Fabricio ASP .Net Building Controls 0 09-21-2005 02:55 AM
Help. SessionID is x then y then x then y BodiKlamph@gmail.com ASP General 0 09-03-2005 03:02 PM
1. Ruby result: 101 seconds , 2. Java result:9.8 seconds, 3. Perl result:62 seconds Michael Tan Ruby 32 07-21-2005 03:23 PM
custom WebControl sometimes doesn't render at design time redcrystal@msn.com ASP .Net Building Controls 1 03-23-2005 10:44 PM
client side script, then server side Mortar ASP .Net 4 01-25-2005 12:29 AM



Advertisments