Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Error when using Gridview in user control and send as a string to jquery ajax

$
0
0

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();
UCFiles
UCFiles=(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);
}
});




Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>