Loading html through .ashx file
I'm trying to inject html into a dialog box using a .ashx file. I'm
noticing in Firebug that my code does the post and then makes a series
of get requests before stopping. Below is the code I'm using. Please
let me know if I need to use a different method. Thanks.
jQuery Code:
//base dialog object
var d = jQuery('#dialog').dialog({
modal: true,
dialogClass: "flora",
bgiframe: true,
autoOpen: false,
overlay: {opacity: 0.5, background: "black"}
});
//sets up dialog and loads subform
jQuery("a[@id*=form]").click(function()
{
var lNum = jQuery(this).attr("id");
lNum = lNum.substring(4, lNum.length);
d.text('Please wait');
d.data('width.dialog', 600);
d.data("height.dialog", 300);
jQuery(d).dialog('open');
d.load(jQuery(this).attr("href") + " fieldset", {lineNumber: lNum},
setFormClick);
return false;
});
.ashx code:
<%@ Webhandler Language="C#" %>
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web;
using System.Text;
public class CustomFormHandler : IHttpHandler
{
public void ProcessRequest (HttpContext context)
{
context.Response.ContentType = "text/html";
string prevCounty = String.Empty
string prevState = String.Empty;
//Get the previous Values
//Note: CDataAccess is a proprietary module used by my
company's hosting provider to handle database transactions instead
of .net's native modules
CDataAccess prevVal = new CDataAccess
(ConfigurationSettings.AppSettings["ConnectionStringiMIS"]);
prevVal.OpenConnection();
prevVal.SelectData("Custom_RCGetPrevOrder01 '" + Request.Form
["lineNumber"] + "'");
if (prevVal.ReadNextRow())
{
//get previous values if any
}
prevVal.CloseConnection();
StringBuilder outputString = new StringBuilder();
outputString.Append("<fieldset id=\"01\" class=
\"generalFieldsetStyle\" style=\"width: auto\">");
outputString.Append("<legend>blah</legend>");
outputString.Append("<input type=\"hidden\" id=\"lineNum\" name=
\"lineNum\" value=\"" + Request.Form["lineNumber"] + "\" />");
//generate the rest of the form data
outputString.Append("</fieldset>");
context.Response.Write(outputString.ToString());
}
public bool IsReusable
{
get
{
return false;
}
}
}