I'll pay you $10 by Paypal if you successfully help me install Text Link Ads on my ASP.net coded site (malluspace.com). I posted over in the programming section but no one seems interested in helping for free. I'm trying to install ads from Text Link Ads on my site's homepage (malluspace.com) and on one interior page. My site is coded in ASP.net. I've attached screenshots of the install instructions from Text Link Ads as well as the error I get on my site when I install their code. I've followed the instructions as best as I know how. I created the 'Controls' directory and inserted the 2 files they provided. I uploaded the xml file they specified and had my host give it write access. http://www.malluspace.com/tla_install_instructions.JPG http://www.malluspace.com/malluspace_tla_error.JPG I can provide the 2 files they provide (*.ascx and *.ascx.cs) Can anyone figure it out?
The files they provide each have the same filename but one has a .ascx suffix and the other a .ascx.cs suffix. They go in the same folder ('Controls') according to their install instructions. They can't both be .ascx as they have the same filename. below is the code from the .ascx file <%@ Control Language="C#" AutoEventWireup="true" CodeFile="textLinkAds.ascx.cs" Inherits="textLinkAds" %> <asp:Literal runat="server" ID="litTextLinkAds" Visible="true" /> Code (markup): Here is the .ascx.cs file using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Text; public partial class textLinkAds : System.Web.UI.UserControl { // these values may be overridden with the control tag, e.g.: // private string strTextLinkAdsID = "128725"; //usually a 5-digit string private string strTextLinkAdsInventoryKey = "FRFZ3CZD9UEAWC6W0X92"; //long alphanumeric string private bool bDebuggingOn = false; // set to false to suppress error messages // do not edit below this point public string textLinkAdsID { get { return strTextLinkAdsID; } set { strTextLinkAdsID = value; } } public string textLinkAdsInventoryKey { get { return strTextLinkAdsInventoryKey; } set { strTextLinkAdsInventoryKey = value; } } private StringBuilder sb = new StringBuilder(); private bool bLinksPresent = false; protected void Page_Load(object sender, EventArgs e) { try { string LOCAL_XML_FILENAME = Server.MapPath("local_"+strTextLinkAdsID+".xml"); string sourceFile = @"http://www.text-link-ads.com/xml.php?inventory_key="+strTextLinkAdsInventoryKey+@"&referer=" + Server.UrlEncode(Request.ServerVariables["HTTP_REFERER"]) + "&user_agent=" + Server.UrlEncode(Request.ServerVariables["HTTP_USER_AGENT"]); System.IO.FileInfo fi = new System.IO.FileInfo(LOCAL_XML_FILENAME); System.DateTime DateMod = System.IO.File.GetLastWriteTime(LOCAL_XML_FILENAME); System.DateTime DateNow = System.DateTime.Now; string Contents = System.IO.File.ReadAllText(LOCAL_XML_FILENAME); if (DateMod < DateNow.AddHours(-1) || fi.Length < 20) { System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(sourceFile); req.Timeout = 10000; System.Net.WebResponse resp = req.GetResponse(); System.IO.Stream stream = resp.GetResponseStream(); System.Xml.XmlTextReader remoteReader = new System.Xml.XmlTextReader(stream); System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(@"<?xml version=""1.0"" encoding=""utf-8""?>"); sb.Insert(sb.Length, System.Environment.NewLine); while (remoteReader.Read()) { sb.Append(remoteReader.ReadOuterXml()); } remoteReader.Close(); string Result = sb.ToString(); if (Result != "") Contents = Result; System.IO.File.WriteAllText(LOCAL_XML_FILENAME, Contents); remoteReader.Close(); } System.Xml.XmlTextReader reader = GetXML(LOCAL_XML_FILENAME); try { System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); doc.Load(reader); System.Xml.XmlElement root = doc.DocumentElement; sb.Append(@"<ul style=""border: 1px solid #FF0000; border-spacing: 0px; background-color: #FFFFFF; overflow: hidden; margin: 0; width: 100%; list-style: none; padding: 0;"">"); if (root.HasChildNodes) { for (int i = 0; i < root.ChildNodes.Count; i++) { string sURL = ""; string sText = ""; string sBeforeText = ""; string sAfterText = ""; System.Xml.XmlNode xnNodeTop = root.ChildNodes[i]; if (xnNodeTop.HasChildNodes) { bLinksPresent = true; for (int z = 0; z < xnNodeTop.ChildNodes.Count; z++) { System.Xml.XmlNode xnNodeChild = xnNodeTop.ChildNodes[z]; if (xnNodeChild.Name == "URL") sURL = xnNodeChild.InnerXml; if (xnNodeChild.Name == "Text") sText = xnNodeChild.InnerXml; if (xnNodeChild.Name == "BeforeText") sBeforeText = xnNodeChild.InnerXml; if (xnNodeChild.Name == "AfterText") sAfterText = xnNodeChild.InnerXml; } } sb.Append(@"<li style=""padding: 0; float: left; display: inline; clear: none; margin: 0; width: 13%;""><span style=""color: #000000; font-size: 12px; display: block; width: 100%; padding: 3px; margin: 0;"">" + sBeforeText + @" <a style=""font-size: 12px; color: #FF0000;"" href=""" + sURL + @""">" + sText + "</a> " + sAfterText + "</span></li>"); } } sb.Append("</ul>"); } catch (Exception ex) { if (bDebuggingOn) sb.Append("Error displaying xml file:<p>" + ex.Message + "</p><p>" + ex.Source + "</p><p>" + ex.StackTrace + "</p>"); } finally { reader.Close(); } } catch (Exception ex) { if (bDebuggingOn) sb.Append("Error displaying xml file:<p>" + ex.Message + "</p><p>" + ex.Source + "</p><p>" + ex.StackTrace + "</p>"); } litTextLinkAds.Text = sb.ToString(); if (!bDebuggingOn && !bLinksPresent) litTextLinkAds.Visible = false; } private System.Xml.XmlTextReader GetXML(string Path) { System.Xml.XmlTextReader reader = null; if (System.IO.File.Exists(Path)) { try { reader = new System.Xml.XmlTextReader(Path); } catch (Exception e) { if (bDebuggingOn) sb.Append("Error displaying xml file - GetXML function:<p>" + e.Message + "</p><p>" + e.Source + "</p><p>" + e.StackTrace + "</p>"); } } return reader; } } Code (markup):
I'm working on getting this site transferred to one of my hosts with cpanel so that I can give access more easily to the site. Right now it's on a really messed up host which doesn't allow me to give exclusive access to only the site affected.