bind user controls dynamically in jquery tabs

Posted by Taanu51 under ASP.NET on 1/24/2013 | Points: 10 | Views : 1775 | Status : [Member] | Replies : 0
hi..

Please provide me the solution how to bind user controls dynamically in jquery tabs..please note that user control contains update panels

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'&quot

Please solve the issue


Thanks

Tanisha Sayyad
.Net and Android Developer
INDIA(Andhra Pradesh)



Responses

(No response found.)

Login to post response