This blog is about the dotnet.all types of codes,news about dotnet including asp.net,vb.net,c# and know about new dotnet technology.programing in asp.net,vb.net,c#, ajax, AJAX tech support for .net and discuss the new technology in dotnet.ncluding asp.net,vb.net,c# and know about new dotnet technology.programing in asp.net,vb.net,c#, ajax, AJAX tech support for .net and discuss the new technology in dotnet.asp.net programming,dot net programming,dotnet programs,dotnet source code,source code.

Free Hosting

Free Hosting

Showing posts with label Code to render a control to HTML. Show all posts
Showing posts with label Code to render a control to HTML. Show all posts

Sunday, November 2, 2008

ASP.NET Code to render a control to HTML

This code shows you how to render a control datagrid,repeater and other controls to a html.

CODE:
private void ClearControls(System.Web.UI.Control control)
{
for (int i=control.Controls.Count -1; i>=0; i--)
{
ClearControls(control.Controls[i]);
}

if (!(control is TableCell))
{
if (control.GetType().GetProperty("SelectedItem") != null)
{
System.Web.UI.LiteralControl literal = new System.Web.UI.LiteralControl();
control.Parent.Controls.Add(literal);
try
{
literal.Text = (string)control.GetType().GetProperty("SelectedItem").GetValue(control,null);
}
catch
{
}
control.Parent.Controls.Remove(control);
}
else
if (control.GetType().GetProperty("Text") != null)
{
System.Web.UI.LiteralControl literal = new System.Web.UI.LiteralControl();
control.Parent.Controls.Add(literal);
literal.Text = (string)control.GetType().GetProperty("Text").GetValue(control,null);
control.Parent.Controls.Remove(control);
}
}
return;
}


private void gethtml(Control dgView,string type,int numofrows)
{
///////create pager
///
int numofpages = 25;

int noofindex = 0;

if(numofrows > numofpages)
{

int div = numofrows / numofpages;
int mod = numofrows % numofpages;

if(mod != 0)
{
div = div + 1;
}
noofindex = div;

}

int g;
string str8="";
string str=" ";
for(g=0;g{
str8 = SF.ToSafeString(g);
if(Request.QueryString["pindex"]!= null)
{
if(str8 == Request.QueryString["pindex"])
{
str8 = "" + str8 + "";
}

}
str += @"" + str8 + " ";
}

System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
this.ClearControls(dgView);
dgView.RenderControl(oHtmlTextWriter);

string str1 = oStringWriter.ToString();
st

dotnet(.Net) Project Source code Downloads and Tutorials

Email Subscrption



Enter your email address:

Delivered by FeedBurner

Feedburner Count

Unique Visitor

Design by araba-cı | MoneyGenerator Blogger Template by GosuBlogger