本文介绍了在jquery选项卡中动态调用用户控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi..
Please provide me the solution how to bind user controls dynamically in jquery tabs..please note that user control contains update panels..
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'"
Thanks
推荐答案
这篇关于在jquery选项卡中动态调用用户控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!