473,385 Members | 1,829 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Get inner html of an HTML element from codebehind file

So, I'm in my code behind file (Page_Load to be exact) and I need to
get the HTML generated by my repeater and save it to a string? How can
I do this, is the HTML even generated at Page_Load time, or do I need
to wait? If so, just tell me to what event, and then how I can get that
HTML to a string in my code behind file.

Thanks,
Alex

Oct 5 '06 #1
5 3922
hi,
if it can help, here's a list of the events fired on a page when it's drawn:

http://weblogs.asp.net/jeff/archive/...04/172683.aspx

I hope it helps

ThunderMusic

<eg****@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
So, I'm in my code behind file (Page_Load to be exact) and I need to
get the HTML generated by my repeater and save it to a string? How can
I do this, is the HTML even generated at Page_Load time, or do I need
to wait? If so, just tell me to what event, and then how I can get that
HTML to a string in my code behind file.

Thanks,
Alex

Oct 5 '06 #2
I figured it out. I just added a flag to my method that builds the
repeater and added this code to the bottom of that method:

if (render)
{
StringBuilder sb= new StringBuilder();

StringWriter sw= new StringWriter(sb);

HtmlTextWriter hw= new
HtmlTextWriter(sw);
RepeaterPapers.RenderControl(hw);

return sb.ToString();

}

So if render is true, it will return immediately with the html of the
repeater!

eg****@gmail.com wrote:
So, I'm in my code behind file (Page_Load to be exact) and I need to
get the HTML generated by my repeater and save it to a string? How can
I do this, is the HTML even generated at Page_Load time, or do I need
to wait? If so, just tell me to what event, and then how I can get that
HTML to a string in my code behind file.

Thanks,
Alex
Oct 5 '06 #3
Please Help me out !! Can I use this to get HTML code of a table
created dynamically on the page ???

eg****@gmail.com wrote:
I figured it out. I just added a flag to my method that builds the
repeater and added this code to the bottom of that method:

if (render)
{
StringBuilder sb= new StringBuilder();

StringWriter sw= new StringWriter(sb);

HtmlTextWriter hw= new
HtmlTextWriter(sw);
RepeaterPapers.RenderControl(hw);

return sb.ToString();

}

So if render is true, it will return immediately with the html of the
repeater!

eg****@gmail.com wrote:
So, I'm in my code behind file (Page_Load to be exact) and I need to
get the HTML generated by my repeater and save it to a string? How can
I do this, is the HTML even generated at Page_Load time, or do I need
to wait? If so, just tell me to what event, and then how I can get that
HTML to a string in my code behind file.

Thanks,
Alex
Oct 5 '06 #4
YES

Aur_Ros wrote:
Please Help me out !! Can I use this to get HTML code of a table
created dynamically on the page ???

eg****@gmail.com wrote:
I figured it out. I just added a flag to my method that builds the
repeater and added this code to the bottom of that method:

if (render)
{
StringBuilder sb= new StringBuilder();

StringWriter sw= new StringWriter(sb);

HtmlTextWriter hw= new
HtmlTextWriter(sw);
RepeaterPapers.RenderControl(hw);

return sb.ToString();

}

So if render is true, it will return immediately with the html of the
repeater!

eg****@gmail.com wrote:
So, I'm in my code behind file (Page_Load to be exact) and I need to
get the HTML generated by my repeater and save it to a string? How can
I do this, is the HTML even generated at Page_Load time, or do I need
to wait? If so, just tell me to what event, and then how I can get that
HTML to a string in my code behind file.
>
Thanks,
Alex
Oct 6 '06 #5
Thanks, YES it worked !!!
eg****@gmail.com wrote:
YES

Aur_Ros wrote:
Please Help me out !! Can I use this to get HTML code of a table
created dynamically on the page ???

eg****@gmail.com wrote:
I figured it out. I just added a flag to my method that builds the
repeater and added this code to the bottom of that method:
>
if (render)
{
StringBuilder sb= new StringBuilder();
>
StringWriter sw= new StringWriter(sb);
>
HtmlTextWriter hw= new
HtmlTextWriter(sw);
RepeaterPapers.RenderControl(hw);
>
return sb.ToString();
>
}
>
So if render is true, it will return immediately with the html of the
repeater!
>
eg****@gmail.com wrote:
So, I'm in my code behind file (Page_Load to be exact) and I need to
get the HTML generated by my repeater and save it to a string? How can
I do this, is the HTML even generated at Page_Load time, or do I need
to wait? If so, just tell me to what event, and then how I can get that
HTML to a string in my code behind file.

Thanks,
Alex
Oct 7 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Victor | last post by:
Hi I need to open an html file from the file system and embed that html file within my main aspx form. I have 2 questions: 1) How do I open the html file? I tried the File.open(Path, mode) didnt...
8
by: Lawrence Oluyede | last post by:
Is there a way to treat html tags like simple text? I explain myself, if I have a bunch of xml like <content type="application/xhtml+xml" xml:base="http://loluyede.blogspot.com" xml:lang="en-US"...
2
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when...
17
by: Lloyd Sheen | last post by:
This IDE is driving me nuts. I needed another button so I copied an existing one, changed the Text and the id and position by drag and drop. Well then I run and get the following: Control...
3
by: mca | last post by:
Hi everyone, I'm new to asp.net and i have a question about separating the html code from the programming code. i have an unknown numbers of entries in my table. I want to make a hyperlink...
4
by: tma | last post by:
I'm trying to retrieve values for my HTML from the Codebehind file and I'm unclear how to accomplish this. For example: <INPUT TYPE="hidden" NAME="amount" VALUE="xx"> How do I populate the...
11
by: tma | last post by:
I have the following HTML in use on my web page. I need it to show a graphic image on the page but do not know what to use in the codebehind to make the graphic appear. If I load the source url in...
4
by: Zuel | last post by:
Hi Folks. So I have a small problem. My DoPostBack function is not writen to the HTML page nor are the asp:buttons calling the DoPostBack. My Goal is to create a totaly dynamic web page where...
3
by: Epetruk | last post by:
Hi, I'm looking for samples of ASP.NET projects where the programming has been done almost entirely using codebehind and classes with very little code in the aspx files themselves. I would...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.