facing problem for loading user control from pagemethod
i have one user control and one aspx page. with the help of jquery i trigger a page method in my aspx file and which will load the user control from the static method. but i am getting error....so i need help please.
my aspx code behind
[System.Web.Services.WebMethod()]
public 开发者_运维问答static string GetOrders(string customerId)
{
//System.Diagnostics.Trace.TraceWarning("In GetOrders");
//System.Threading.Thread.Sleep(500);
Page page = new Page();
CustomerOrders ctl = (CustomerOrders)page.LoadControl("CustomerOrders.ascx");
ctl.CustomerId = customerId;
page.Controls.Add(ctl);
System.IO.StringWriter writer = new System.IO.StringWriter();
HttpContext.Current.Server.Execute(page, writer, false);
string output = writer.ToString();
writer.Close();
return output;
}
the error message i am getting
The type or namespace name 'CustomerOrders' could not be found (are you missing a using directive or an assembly reference?)
please give me the solution.
Make sure you're putting in the full path to your control. Using the ~/
will resolve the root of your application.
CustomerOrders ctl =
page.LoadControl("~/The/Full/Path/CustomerOrders.ascx") as CustomerOrders;
精彩评论