I have a user control with a gridview and call from a web method. This works fine from local machine and show the data in gridview but when I publish the website on the server gridview doesn’t show and ajax error shows :Internal server error.
user control:
<div> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="true"> </asp:GridView></div>
[WebMethod(EnableSession=true)]
publicstaticstringGetSelectedFolder(intFolderID)
{
Page page =newPage();
UCFilesUCFiles=(UCFiles)page.LoadControl("uc/UCFiles.ascx");
UCFiles.ID ="ucUpload"; page.Controls.Add(UCFiles);HtmlForm tempForm =newHtmlForm();
tempForm.Controls.Add(UCFiles);
page.Controls.Add(tempForm);StringWriter output =newStringWriter();
HttpContext.Current.Server.Execute(page, output,false);
string outputToReturn = output.ToString();
// HttpContext.Current.Server.HtmlEncode(outputToReturn, output);
//outputToReturn = outputToReturn.Substring(outputToReturn.IndexOf("<div>"));
//outputToReturn = outputToReturn.Substring(0, outputToReturn.IndexOf("</form>"));
return outputToReturn;
$.ajax({
type:"POST",
url:"File.aspx/GetSelectedFolder",
contentType:"application/json; charset=utf-8",
data:"{'FolderID': '"+ jQuery.attr(data.rslt.obj[0],"id")+"'}",
dataType:"json",
success:function(response)
{
alert(response.d);
$("#div2").html(response.d);
},
error:function(XMLHttpRequest, textStatus, errorThrown)
{
alert("Status: "+ textStatus); alert("Error: "+ errorThrown);
}
});