There are a lot of websites on the Internet. It seems that I was reading Lao Zhao at first. I just wrote it as static:
Public Static String Asyncloadcontrol <t> ( String Virtualpath, Action <t> Act) Where T: usercontrol
{
Page P = New Page ();
T UC = (t) p. loadcontrol (virtualpath );
Act (UC );
P. Controls. Add (UC );
Stringwriter writer = New Stringwriter ();
Httpcontext. Current. server. Execute (p, writer, False );
Return Writer. tostring ();
}
Public Static String Asyncloadcontrol ( String Virtualpath)
{
Page P = New Page ();
Control UC = P. loadcontrol (virtualpath );
P. Controls. Add (UC );
Stringwriter writer = New Stringwriter ();
Httpcontext. Current. server. Execute (p, writer, False );
Return Writer. tostring ();
}
Call:
// Passing Parameters
String Result = pagehelper. asyncloadcontrol <strongtest. UC. News> ( " ~ /UC/news. ascx " ,
UC =>
{
UC. pagesize = 5 ;
UC. pageindex = 1 ;
}); // No parameter is required
String Result = pagehelper. asyncloadcontrol ( " ~ /UC/comments. ascx " );