Convert input field string in the table to the input field?
<%= HttpUtility.HtmlDecode((string)objRow["Post"]) %>
On view End
<%= HttpUtility.HtmlDecode(GetUsersList())%>
Code In Cs File
foreach (DataRow dtRow in ds.Tables[0].Rows)
{
string userpk = Convert.ToString(dtRow["user_pk"]);
string usertypecd = Convert.ToString(dtRow["user_type_cd"]);
string firstname = Convert.ToString(dtRow["first_name"]);
string lastname = Convert.ToString(dtRow["last_name"]);
string active = Convert.ToString(dtRow["active_ind"]);
if (active == "true")
{
active = "< input type = 'checkbox' class='editor-active' disabled='disabled' checked='checked'>";
}
else {
active = "< input type = 'checkbox' class='editor-active' disabled='disabled'>";
}
string phoneno = Convert.ToString(dtRow["phone_no"]);
string phone_ext = Convert.ToString(dtRow["phone_ext"]);
string email = Convert.ToString(dtRow["email"]);
content += "<tr><td>"+ usertypecd+ "</td><td>" + firstname + "</td><td>" + lastname + "</td><td>" + active + "</td><td>" + phoneno + "</td><td>" + phone_ext + "</td><td>" + email + "</td><td></td></tr>";
}
return content;
Result Image:
If you mean Asp-WebForms you can create a System.Web.Label with the html text in the Text Property. This will then render as HTML if you add the control to your page.
Alternatively you can just dump the text into a protected/public property and use <%= YourPropertyNameHere %> to dump the text as it is into the page.
Personally through I recommend you build your web controls instead of string operations. For example create a System.Web.Panel and then add your html controls to it as you need them.
var pnl = new Panel();
var cb = new CheckBox();
cb.Enabled = (active == "true");
cb.Checked = cb.Enabled;
cb.CssClass = "editor-active";
pnl.Controls.Add(cb);
SomePanelInFrontCode.Controls.Add(pnl);
Related
i have a problem concerning a breadcrumb navigation.
In my application i have a Start.aspx where i build a navigation menu for the next module (control1.ascx, control2.ascx, ...) which should be loaded after clicking.
This ascx contains a grid with some data rows and link buttons to load other ascx on the start page
This is the common way the app works.
Now i need to visualize which ascx is loaded in the breadcrumb
Maybe we can viaualize it like this:
Start.aspx -> control1.ascx -> control1_1.ascx
Right now the app would be on the lowest level and if i click on "control1.ascx" this control should be loaded again or if i choose Start.aspx the "Home" should be loaded.
protected override void Render(HtmlTextWriter output)
{
NavigationDataTable moduleNameList = new NavigationDataTable();
List<usp_GetNavigationElements_Result> ModuleList = moduleNameList.GetModulesList(1, LoggedInUser);
StringBuilder sbResult1 = new StringBuilder();
//string sbResult;
if (Page.Items["title"] != null)
{
string id = Page.Items["title"].ToString();
PageTitle = Page.Items["title"].ToString();
}
//------------------------------------------------------------------------------------------
var request = HttpContext.Current.Request;
System.Collections.Specialized.NameValueCollection coll;
// Load ServerVariable collection into NameValueCollection object.
coll = request.ServerVariables;
string serverName = request.ServerVariables["SERVER_NAME"];
//------------------------------------------------------------------------------------------
string strDomain = "";
if (serverName == "localhost")
{
//Lokal
strDomain = "localhost:49573";
}
else
{
//Intranet
strDomain = "i";
}
string strURL = "/Start.aspx";
string strDirs = "control1.ascx";
Separator3 = new Image();
Separator3.Height = 52;
Separator3.Width = 52;
ArrowSeparator = new Image();
ArrowSeparator.ImageUrl = "/img/mb_arrow_separator.png";
HomeSymbol = new Image();
HomeSymbol.ImageUrl = "/img/mb_home.png";
// Home-Navigation for Start
sbResult1.Append("<img src='" + HomeSymbol.ImageUrl + "'>");
sbResult1.Append("<a href='http://" + strDomain + "/modules" + strURL + "'style='text-decoration:none;'>" + RootName + " " + "</a>");
sbResult1.Append("<img src='" + ArrowSeparator.ImageUrl + "' hspace='10'>");
//-------------------------------------------------------------------------------------------------------------------------------
foreach (var item in ModuleList)
{
if (HttpContext.Current.Session["ModuleTitle"] != null)
{
if (item.ModuleTitle == HttpContext.Current.Session["ModuleTitle"].ToString() )
{
//sbResult1.Append("<a href='http://" + strDomain + "/modules" + strURL + "?" + item.ModuleName + "'>" + item.ModuleTitle + "</a>" + Separator);
Separator3.ImageUrl = "/img/" + HttpContext.Current.Session["ModuleTitle"].ToString() + ".png";
sbResult1.Append("<img src='" + Separator3.ImageUrl + " 'hspace='10'>");
sbResult1.Append(HttpContext.Current.Session["ModuleTitle"]).ToString();
}
}
}
if (!ModuleList.Contains(HttpContext.Current.Session["ModuleTitle"]))
{
if (HttpContext.Current.Session["ModuleTitle"] != null)
{
if (HttpContext.Current.Session["ModuleTitle"].ToString().Contains("_"))//|| HttpContext.Current.Session["ModuleSubTitle"] != null)
{
string[] std = HttpContext.Current.Session["ModuleTitle"].ToString().Split('_');
Separator3.ImageUrl = "/img/" + std[0] + ".png";
sbResult1.Append("<img src='" + Separator3.ImageUrl + "' hspace='10'>");
sbResult1.Append("<a href='http://" + strDomain + "/modules" + strURL + "?" + std[0] + "'style='text-decoration:none;'>" + std[0] + " " + "</a>");
sbResult1.Append("<img src='" + ArrowSeparator.ImageUrl + "' hspace='10'>");
sbResult1.Append("<img src='/img/Prozess.png' hspace='10'>");
sbResult1.Append(std[1]);
}
}
}
//-------------------------------------------------------------------------------------------------------------------------------
output.Write(sbResult1.ToString());
}
Do i have to make this Breadcrumb.cs and override Render() or is there a better way.
Greets DarkGecko
have you considered a SiteMapPath?
<asp:SiteMapPath ID="SiteMapPath1" Runat="server"></asp:SiteMapPath>
https://msdn.microsoft.com/en-us/library/x20z8c51.aspx
I have got this new project that I am not familiar in working with. One task is that I need to navigate some websites to collect some data. One sample website would be this: https://www.hudhomestore.com/Home/Index.aspx
I have read and watched tutorials on "collecting" data from a web page, such as:
How to Scrape HTML Data with C#
Reading data from a website using C#
Pulling data from a webpage, parsing it for specific pieces, and displaying it
But my question is how do we usually set preferences, to "search" based on our preferences, and then use the above links to load the results in my code?
EDIT
This is correct for setting the searching criteria based on my selection. However, total count of the search (If I do it manually for MI state) is 223, but i I execute the below code, tdNodeCollection is only 121. Can you show me where am I going wrong?
HtmlWeb web = new HtmlWeb();
HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
string zipCode = "", city = "", county = "", street = "", sState = "MI", fromPrice = "0", toPrice = "0", fcaseNumber = "",
bed = "0", bath = "0", buyerType = "0", Status = "0", indoorAmenities = "", outdoorAmenities = "", housingType = "",
stories = "", parking = "", propertyAge = "", sLanguage = "ENGLISH";
var doc = await (Task.Factory.StartNew(() => web.Load("https://www.hudhomestore.com/Listing/PropertySearchResult.aspx?" +
"zipCode=" + zipCode + "&city=" + city + "&country=" + county + "&street=" + street + "&sState=" + sState +
"&fromPrice=" + fromPrice + "&toPrice=" + toPrice +
"&fcaseNumber=" + fcaseNumber + "&bed=" + bed + "&bath=" + bath +
"&buyerType=" + buyerType + "&Status=" + Status + "&indoorAmenities=" + indoorAmenities +
"&outdoorAmenities=" + outdoorAmenities + "&housingType=" + housingType + "&stories=" + stories +
"&parking=" + parking + "&propertyAge=" + propertyAge + "&sLanguage=" + sLanguage)));
HtmlNodeCollection tdNodeCollection = doc
.DocumentNode
.SelectNodes("//*[#id=\"dgPropertyList\"]//tr//td");
You can make use of HTMLAgilityPack for this purpose. I've made a small testing code and tested with the second page you wish to scrap based on the search criteria which you can set.
HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
HtmlWeb web = new HtmlWeb();
//string InitialUrl = "https://www.hudhomestore.com/Home/Index.aspx";
//Here you need to set the values of these variable to whatever user inputs
//after setting these values, add them to initial URL
string zipCode = "", city = "", county = "", street = "", sState = "AK", fromPrice = "0", toPrice = "0", fcaseNumber = "",
bed = "0", bath = "0", buyerType = "0", Status = "0", indoorAmenities = "", outdoorAmenities = "", housingType = "",
stories = "", parking = "", propertyAge = "", sLanguage = "ENGLISH";
HtmlAgilityPack.HtmlDocument document = web.Load("https://www.hudhomestore.com/Listing/PropertySearchResult.aspx?" +
"zipCode=" + zipCode + "&city=" + city + "&country=" + county + "&street=" + street + "&sState=" + sState +
"&fromPrice=" + fromPrice + "&toPrice=" + toPrice +
"&fcaseNumber=" + fcaseNumber + "&bed=" + bed + "&bath=" + bath +
"&buyerType=" + buyerType + "&Status=" + Status + "&indoorAmenities=" + indoorAmenities +
"&outdoorAmenities=" +outdoorAmenities + "&housingType=" + housingType + "&stories=" + stories +
"&parking=" + parking + "&propertyAge=" + propertyAge + "&sLanguage=" + sLanguage);
HtmlNodeCollection tdNodeCollection = document
.DocumentNode
.SelectNodes("//*[#id=\"dgPropertyList\"]//tr//td");
Count them again and look at your expression, there are exactly 121 td's within tr with id="dgPropertyList"
Next, check your td manually and trace what you need from that td and fetch that data.
foreach (HtmlAgilityPack.HtmlNode node in tdNodeCollection)
{
//Do you say you want to access to <h2>, <p> here?
//You can do:
HtmlNode h2Node = node.SelectSingleNode("./h2"); //That will get the first <h2> node
HtmlNodeCollection allH2Nodes = node.SelectNodes(".//h2"); //That will search in depth too
//And you can also take a look at the children, without using XPath (like in a tree):
HtmlNode h2Node_ = node.ChildNodes["h2"];
}
I've tested the code, it works and parse the whole document to reach the required table. It will get you all the rows within that table inside div. So, you can further dig into these rows, find your td and get what you need.
Another option could be using Selenium webdriver, Get your hands on Selenium
If you don't want the browser to be visible and still want to use Selenium like functionality then you can make use of PhantomJS
Hope it helps.
I'm currently building a small website that takes data from 6 different web forms written in ASP.NET and C#. I need all of the information to be written to a PDF at the end of Page 6. I currently have all fields mapped, but each time the page changes, the information gets wiped. i have the information set to pass the values using a query string, but it seems to keep getting lost. Any advice?
EDIT
Sorry for not posting the code the first time, this is my first question i ever posted here. Also, I know my code isn't very efficient, I'm more or less trying to get the grasp of iTextSharp and WebForms. Thanks
Page 1
AcroFields af = ps.AcroFields;
af.SetField("Name", name.Text);
af.SetField("Email", email.Text);
af.SetField("state", state.Text);
af.SetField("city", city.Text);
af.SetField("Address", address.Text);
af.SetField("Phone", phone.Text);
af.SetField("zip", zip.Text);
Response.Redirect("Default.aspx?name=" + this.name.Text + "&Email=" + this.email.Text
+ "&state=" + this.state.Text + "&city=" + this.city.Text + "&Address=" + this.address.Text +
"&Phone=" + this.phone.Text + "&zip=" + this.zip.Text);
Response.Redirect("Page2.aspx");
Page 2
AcroFields af = ps.AcroFields;
af.SetField("Degree", degree.Text);
af.SetField("Grad", gradDate.Text);
af.SetField("Obj", objective.Text);
Response.Redirect("Default.aspx?Degree=" + this.degree.Text + "&Grad=" + this.gradDate.Text
+ "&Obj=" + this.objective.Text);
Response.Redirect("Page3.aspx");
//ps.FormFlattening = true;
Page 3
AcroFields af = ps.AcroFields;
af.SetField("jobStart1", jobStart1.Text);
af.SetField("jobEnd1", jobEnd1.Text);
af.SetField("jobTitle1", jobTitle1.Text);
af.SetField("coName1", coName1.Text);
af.SetField("coAdd1", coAdd1.Text);
af.SetField("Details1", details1.Text);
Response.Redirect("Default.aspx?jobStart1" + this.jobStart1.Text + "&jobEnd1=" + this.jobEnd1.Text
+ "&jobTitle1=" + this.jobTitle1.Text + "&coName1=" + this.coName1.Text + "&coAdd1=" + this.coAdd1.Text +
"&Details1=" + this.details1.Text);
Response.Redirect("Page4.aspx");
Page 4
AcroFields af = ps.AcroFields;
af.SetField("jobStart2", jobStart2.Text);
af.SetField("jobEnd2", jobEnd2.Text);
af.SetField("jobTitle2", jobTitle2.Text);
af.SetField("coName2", coName2.Text);
af.SetField("coAdd2", coAdd2.Text);
af.SetField("Details2", details2.Text);
Response.Redirect("Default.aspx?jobStart2" + this.jobStart2.Text + "&jobEnd2=" + this.jobEnd2.Text
+ "&jobTitle2=" + this.jobTitle2.Text + "&coName2=" + this.coName2.Text + "&coAdd2=" + this.coAdd2.Text +
"&Details2=" + this.details2.Text);
Response.Redirect("Page5.aspx");
Page 5
AcroFields af = ps.AcroFields;
af.SetField("jobStart3", jobStart3.Text);
af.SetField("jobEnd3", jobEnd3.Text);
af.SetField("jobTitle3", jobTitle3.Text);
af.SetField("coName3", coName3.Text);
af.SetField("coAdd3", coAdd3.Text);
af.SetField("Details3", details3.Text);
Response.Redirect("Default.aspx?jobStart3" + this.jobStart3.Text + "&jobEnd3=" + this.jobEnd3.Text
+ "&jobTitle3=" + this.jobTitle3.Text + "&coName3=" + this.coName3.Text + "&coAdd3=" + this.coAdd3.Text +
"&Details3=" + this.details3.Text);
Response.Redirect("Page6.aspx");
Page 6
string name = Request.QueryString["Name"];
string address = Request.QueryString["Address"];
string phone = Request.QueryString["Phone"];
string email = Request.QueryString["Email"];
string city = Request.QueryString["city"];
string state = Request.QueryString["state"];
string zip = Request.QueryString["zip"];
string degree = Request.QueryString["Degree"];
string gradDate = Request.QueryString["Grad"];
string objective = Request.QueryString["Obj"];
string jobStart1 = Request.QueryString["jobStart1"];
string jobEnd1 = Request.QueryString["jobEnd1"];
string jobTitle1 = Request.QueryString["jobTitle1"];
string coName1 = Request.QueryString["coName1"];
string coAdd1 = Request.QueryString["coAdd1"];
string details1 = Request.QueryString["Details1"];
string jobStart2 = Request.QueryString["jobStart2"];
string jobEnd2 = Request.QueryString["jobEnd2"];
string jobTitle2 = Request.QueryString["jobTitle2"];
string coName2 = Request.QueryString["coName2"];
string coAdd2 = Request.QueryString["coAdd2"];
string details2 = Request.QueryString["Details2"];
string jobStart3 = Request.QueryString["jobStart3"];
string jobEnd3 = Request.QueryString["jobEnd3"];
string jobTitle3 = Request.QueryString["jobTitle3"];
string coName3 = Request.QueryString["coName3"];
string coAdd3 = Request.QueryString["coAdd3"];
string details3 = Request.QueryString["Details3"];
AcroFields af = ps.AcroFields;
af.SetField("Name", name);
af.SetField("Email", email);
af.SetField("state", state);
af.SetField("city", city);
af.SetField("Address", address);
af.SetField("Phone", phone);
af.SetField("zip", zip);
af.SetField("Degree", degree);
af.SetField("Grad", gradDate);
af.SetField("Obj", objective);
af.SetField("jobStart1", jobStart1);
af.SetField("jobEnd1", jobEnd1);
af.SetField("jobTitle1", jobTitle1);
af.SetField("coName1", coName1);
af.SetField("coAdd1", coAdd1);
af.SetField("Details1", details1);
af.SetField("jobStart2", jobStart2);
af.SetField("jobEnd2", jobEnd2);
af.SetField("jobTitle2", jobTitle2);
af.SetField("coName2", coName2);
af.SetField("coAdd2", coAdd2);
af.SetField("Details2", details2);
af.SetField("jobStart3", jobStart3);
af.SetField("jobEnd3", jobEnd3);
af.SetField("jobTitle3", jobTitle3);
af.SetField("coName3", coName3);
af.SetField("coAdd3", coAdd3);
af.SetField("Details3", details3);
af.SetField("Skills", skills.Text);
ps.FormFlattening = true;
}
Response.End();
Response.Redirect("Default.aspx?name=" + this.name.Text + "&Email=" + this.email.Text
+ "&state=" + this.state.Text + "&city=" + this.city.Text + "&Address=" + this.address.Text +
"&Phone=" + this.phone.Text + "&zip=" + this.zip.Text);
Response.Redirect("Page2.aspx"); //this will never be reached because the line before it ends the current execution context
You're redirecting back to Default.aspx, but judging by your question the intention is to go to Page2.aspx. But Response.Redirect("Page2.aspx"); is never reached because the response ends after the first redirect. When you call response redirect (the standard overload) the current request context ends, the client is sent an HTTP redirect. So no further code will be executed.
Instead, replace both of those lines with this one:
Response.Redirect("Page2.aspx?name=" + this.name.Text + "&Email=" + this.email.Text
+ "&state=" + this.state.Text + "&city=" + this.city.Text + "&Address=" + this.address.Text +
"&Phone=" + this.phone.Text + "&zip=" + this.zip.Text);
Then on Page 2, you'll need code in Page_Load to pull the values out of the request query string, and additional code so that when you leave the page you pass the values from page 1 and the new values from page 2. And so on.
You should UriEncode your values before putting them in the query string. And concatenating a bunch of strings is really ugly. Perhaps a format string would be appropriate here.
Also, if I were you, I'd abandon the query string approach entirely. That's really messy, passing them around like that because after several pages, you're going to have a ton of parameters and it's going to be a messy URL and a lot of boilerplate code. And neither of those is good. Instead, you should create a Model to represent all the information you want to gather, then store the model somewhere such as Session to pass it between pages. On the function where you build your PDF, have it accept the model as a parameter and generate the PDF according to the values in your model.
The model is simply a C# class that represents the values your PDF needs. For example, here's a starting point:
public class ApplicantInformationModel
{
public string Name {get; set;}
public string Email {get; set;}
public List<Job> Jobs {get; set;}
public string PhoneNumber {get; set;}
}
public class Job
{
public DateTime StartDate {get; set;}
public DateTime EndDate {get; set;}
public string Title {get; set;}
public string Company {get; set;}
}
Your PDF creation function will accept this:
public static Document GeneratePdfForApplicant(ApplicantInformationModel model)
{
//use iTextSharp to generate and return PDF based on the model
}
I have this problem
string text = Html.Raw(immobileTmp.Localita + "\n" + immobileTmp.PrezzoVendita).ToString();
#Html.ActionLink(text, "DettaglioImmobile", "Immobili", new { id = immobileTmp.Id }, null)
but then no new line is in output just <br /> between the 2 strings.
Then I tried
string text = Html.Raw(HttpUtility.HtmlEncode(immobileTmp.Localita + "\n" + immobileTmp.PrezzoVendita).Replace("\n", "<br/>")).ToHtmlString();
#Html.ActionLink(text, "DettaglioImmobile", "Immobili", new { id = immobileTmp.Id }, null)
but had no better luck.
Any ideas?
I guess you need to insert two </ br>, did you tried that ?
UPDATE
Try Environment.NewLine, like that:
string text = Html.Raw(immobileTmp.Localita + Environment.NewLine + immobileTmp.PrezzoVendita).ToString();
#Html.ActionLink(text, "DettaglioImmobile", "Immobili", new { id = immobileTmp.Id }, null)
Try this:
String s1 = (immobileTmp.Localita).ToString() + " ";
String s2 = (immobileTmp.PrezzoVendita).ToString();
String s = s1 + s2
StringBuilder sb = new StringBuilder(s);
int i = 0;
while ((i = sb.indexOf(" ", i + s1.Length)) != -1) {
sb.replace(i, i + 1, "\n");
}
string text = Html.Raw(s);
If you join the strings with Environment.NewLine wrapping the tag in a <pre> splits the lines as you want, as in this sample:
#{
string sep = Environment.NewLine;
string text = Html.Raw(immobileTmp.Localita + sep + immobileTmp.PrezzoVendita).ToString();
}
<pre>
#Html.ActionLink(text, "DettaglioImmobile", "Immobili", new { id = immobileTmp.Id }, null)
</pre>
Gotcha: the text will be formatted as monospaced (because of the <pre>) but CSS can take care of that (<pre class="blah">...).
I'm using the local database functionality in Chrome and Safari and what I do when I want to save this to a remote database is to create a hidden textfield and then using JSON to stringify each row. In the code behind I then parse each JSON object and insert it into the list. What I want to do now is to delete these rows from the local database. I have a JavaScript function called deletePatient:
function deletePatient(patientID) {
MaRDB.transaction(
function (transaction) {
transaction.executeSql("DELETE FROM Patients WHERE id = " + patientID + ";");
}
);
}
I then call this function from the code behind if the insert was successfull
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Delete", "<script language='javascript'>$(document).ready(function() {deletePatient(" + id + ");});</script>");
However, it only deletes the patient with the lowest ID (the first JSON object). When I step through the code it goes back to that code for each ID but only deletes one. If I try with an alert it also only shows one ID even though it iterates through the code N number of times. I guess it's some kind of conflict with postback and executing a JavaScript function here but is it possible to solve?
protected void btnSave_Click(object sender, EventArgs e)
{
bool successfullySent = false;
SharePointConnection();
int count = Convert.ToInt32(txtRows.Text);
for (int i = 0; i <= count; i++)
{
string p = String.Format("{0}", Request.Form["hiddenField" + i]).ToString();
JObject o = JObject.Parse(p);
id = (int)o["id"];
string name = (string)o["name"];
string address = (string)o["address"];
string city = (string)o["city"];
string state = (string)o["state"];
string zip = (string)o["zip"];
string country = (string)o["country"];
string phone = (string)o["phone"];
StringBuilder sb_method = new StringBuilder();
sb_method.Append("<Method ID='1' Cmd='New'>");
sb_method.Append("<Field Name='Title'>" + name + "</Field>");
sb_method.Append("<Field Name='Address'>" + address + "</Field>");
sb_method.Append("<Field Name='City'>" + city + "</Field>");
sb_method.Append("<Field Name='State'>" + state + "</Field>");
sb_method.Append("<Field Name='ZIP'>" + zip + "</Field>");
sb_method.Append("<Field Name='Country'>" + country + "</Field>");
sb_method.Append("<Field Name='Phone'>" + phone + "</Field>");
sb_method.Append("</Method>");
XmlDocument x_doc = new XmlDocument();
XmlElement xe_batch = x_doc.CreateElement("Batch");
xe_batch.SetAttribute("OnError", "Continue");
xe_batch.InnerXml = sb_method.ToString();
try
{
//updating the list
XmlNode xn_return = listsObj.UpdateListItems(ConfigurationManager.AppSettings["SaveToSPList"].ToString(), xe_batch);
if (xn_return.InnerText == "0x00000000")
{
successfullySent = true;
}
else
{
successfullySent = false;
}
}
catch
{
successfullySent = false;
}
if (successfullySent)
{
divSuccessfulMessage.Visible = true;
lblSuccessfulMessage.Text = "Report Successfully Saved";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Delete", "<script language='javascript'>$(document).ready(function() {deletePatient(" + id + ");});</script>");
}
else
{
divErrorMessage.Visible = true;
lblErrorMessage.Text = "Failed to Save, Please Try Again";
}
}
}
Thanks in advance.
I'm assuming you're calling the RegisterClientScriptBlock multiple times? In that case, the second parameter of your RegisterClientScriptBlock is the unique key of the script you're trying to inject. Since its always the same, in effect you're basically 'overwriting' each previous script with the latest one.
Try it again, and make sure your key is unique every time you call the RegisterClientScriptBlock (for example, append a counter to it?).
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Delete" + counter.ToString(), "<script language='javascript'>$(document).ready(function() {deletePatient(" + id + ");});</script>");