It might be a problem with the RenderChildren method of your parent control. If you just want the content, try doing userControl.RenderControl() to an HtmlTextWriter and view the content of that. If you get an error again, the problem is rendering your custom
control.
developersco...
Member
6 Points
4 Posts
Bind user controls dynamically in jquery tabs
Jan 24, 2013 08:17 AM|LINK
Hi..
I am trying to create a tab container using jquery.its successfully created.
<div class="content">
<div id="myTabs" style="width: 600px;">
<ul>
<li><a href="#tab0">one</a></li>
<li><a href="#tab1">two</a></li>
</ul>
<div id="tab0"></div>
Next,used the jquery ajax to pass the control name
$(function () {
var $tabs = $("#myTabs").tabs({
select: function (e, ui) {
thistab = ui.index;
$("#tab" + thistab).html(getUsercontrol(thistab));
}
});
});
function getUsercontrol(thistab) {
switch (thistab) {
case 0:
userControlName = "ctrlOne.ascx";
break
case 1:
userControlName = "ctrltwo.ascx";
break;
}
$.ajax({
type: "POST",
url: "frmCLClaims.aspx/GetUserControl",
data: "{controlName:'" + userControlName + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
$("#tab" + thistab).html(result.d);
}
});
}
in aspx.cs page ..created the web method like this
[WebMethod]
public static string GetUserControl(string controlName)
{
using (Page page = new Page())
{
HtmlForm form = new HtmlForm();
UserControl userControl = (UserControl)page.LoadControl("~/PL/Claims/UserControls/" + controlName);
form.Controls.Add(userControl);
using (StringWriter writer = new StringWriter())
{
page.Controls.Add(form);
HttpContext.Current.Server.Execute(page, writer, false);
return writer.ToString();
}
}
}
Error raises in this line.
HttpContext.Current.Server.Execute(page, writer, false);
Error : Error executing child request for handler 'System.Web.UI.Page'"
Please solve the issue
medelbrock
Member
637 Points
138 Posts
Re: Bind user controls dynamically in jquery tabs
Jan 24, 2013 04:06 PM|LINK
It might be a problem with the RenderChildren method of your parent control. If you just want the content, try doing userControl.RenderControl() to an HtmlTextWriter and view the content of that. If you get an error again, the problem is rendering your custom control.
mebinici
Participant
815 Points
256 Posts
Re: Bind user controls dynamically in jquery tabs
Jan 24, 2013 10:34 PM|LINK
Did you try to debug and put a break point in the method?
The instance may be null, so you will have to verify.
Love collecting video games, movies and board games!
Enjoying my '11 WRX, so sexy...