Jump to content

jesh

Members
  • Posts

    2,293
  • Joined

  • Last visited

Posts posted by jesh

  1. As far as I know, the answer to your question is no. It is not possible to do this to render a LinkButton to the page:

    myLabel.Text = "blah blah blah <asp:LinkButton ID=\"SomeLinkButton\" runat=\"server\" />";

    Your label will simply read "blah blah blah <asp:LinkButton ID="SomeLinkButton" runat="server" />" and the server tag won't ever be built.One trick I've discovered when I've come across situations like yours is to view the source code that is rendered and see what .NET is doing with my code. The reason I think this would help you is that you can sort of trick .NET into thinking that a PostBack has occurred by writing your own onclick event into the links.Try this. Put the following in a page and render it out to the browser:

    <asp:Label id="myLabel" runat="server">blah blah blah <asp:LinkButton id="myLinkButton" OnClick="myLinkButton_Click" runat="sever" Text="Page 2" /> blah blah</asp:Label>

    The code that is sent to the browser will look something like this:

    <span id="myLabel">blah blah blah <a id="myLinkButton" onclick="__doPostBack('myFormName$myLinkButton');">Page 2</a> blah blah</span>

    So, rather than have .NET write the rendered code, you can try to write it yourself. This way, you can dynamically set the Text for your Label like so:

    myLabel.Text = "blah blah blah <a id=\"myLinkButton\" onclick=\"__doPostBack('myFormName$myLinkButton');\">Page 2</a> blah blah";

    Of course, this is a total hack and, as such, you'll most likely have to play around with it a bit to get it to work correctly for you. I've used it a number of times to great advantage.

  2. Alright, online it is then! thanks for your help, I will post on this topic only if I have any more problems!
    Me too, Prateek. I've only read one book on javascript (it was an O'Reilly book), the rest I've learned from playing and from reading online.
  3. I wrote an object to simulate HTMLElement.prototype in all browsers
    //					//	IE doesn't allow access to HTMLElement					//	so we need to override 					//	*document.createElement					//	*document.getElementById					//	*document.getElementsByTagName					//

    Hah! So IE doesn't allow you to extend the HTMLElement, but it doesn't have any problems with you completely overriding document.createElement and document.getElementById!? All I can do is shake my head...Nice work, aspnetguy.
  4. Yes im using a form connected to an asp page. I have not included any cookies or sessions that im aware of so that sounds like the way to go? Thanks
    That's right. In order to keep track of who is visiting a certain page, you have to store that person's UserID in either the Session or in a cookie. Then, when it comes time to save the file, you look at the Session (or cookie) to get the UserID and then you can insert a record in the database with the filename and the user's UserID.
  5. Are you allowing them to upload files by presenting them with a form that has an input of type file and posts to some ASP page?

    <form action="upload.asp" method="POST" enctype="multipart/form-data"><input type="file" id="uploadFile" /><input type="submit" value="Upload the file!" /></form>

    Or are you providing them access to your site through an FTP program?If you are using ASP, are you keeping track of who is viewing the page? Either by placing a cookie on that person's computer or using Sessions?

  6. Thanks for your reply jesh. I don't think that web services work in this way though. Correct me If I'm wrong but I think I cannot control the way dates are captured since I'm not the one developing the consumer. The only thing I could do is having three fileds for year, month, days like you suggested.
    Yeah, that's right since you aren't able to control the consumers. I would guess that you would minimize errors if the structure of the date in the request looked something along the lines of:
    <date>  <month>3</month>  <day>14</day>  <year>2007</year></date>

  7. As for your problem... not having the complete site map file here is probably what confuses me, so I'll work with what I have.
    I've suddenly become interested in learning more about this. heh.Here's a sample of an entire Web.sitemap file. I believe that the only elements allowed are siteMap and siteMapNode:
    <?xml version="1.0" encoding="utf-8" ?><siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" > <siteMapNode url="~/Default.aspx" title="Home" description="This is the home page."> <siteMapNode url="~/AboutUs.aspx" title="About Us" description="This is an about us page." /> <siteMapNode url="~/Contact.aspx" title="Contact Us" description="Send us some stuff." /> </siteMapNode></siteMap>
    In siteMap, there can be only one siteMapNode, but there can be many siteMapNode elements within that first siteMapNode and you can nest more siteMapNodes in the children siteMapNodes.I think, for the sake of future compliance, you're probably corrrect that the best bet would be to simply write your own sitemap XML file and use XSLT to transform it into the format you need rather than rely on .NETs .sitemap file structure.
  8. Are you currently already storing the file names and user ids in your database? How are your users able to upload files and are they then able to view those files at a later time? If so, all the data that you need is probably already there. Give us some more information about your database structure and describe in more detail the process you are using to allow the users to upload files and we may be able to help.

  9. the object oyu what to extend is HTMLElement. Unfortunately IE doesn't let you extend it. you will need to create a function that would scan the DOM and attach your function to every element unless you create the dom dynamically using the function I showed earlier.
    Yeah, I just ran into IE's little prevention yesterday on a different project. Punks. I wanted to add an addEventListener method to HTMLElements so that I could do it in a cross-browser way (rather than use addEventListener in DOM Compliant browsers and attachEvent in IE). So, I ended up doing what aspnetguy did - I wrote a stand-alone function.Instead of element.addEventListener("click", myhandler), I have to call addEventListener(element, "click", myhandler).
  10. Data type mismatch in criteria expression.
    Maybe it's the way you are passing the date. Many database management systems store dates in the YYYY/MM/dd format. Try this query:
    INSERT INTO emails (email,[date]) VALUES ('admin@enterf2.co.uk','2007/03/13')

    EDIT: Also try "2007-03-13".

  11. Rather than messing around with positioning, you might consider using float.HTML:

    <body><div id="container">  <div id="menu">....</div>  <div id="content">...</div></div></body>

    CSS:

    #container { padding-top: 266px; }#menu { float: right; width: 170px; }

  12. Just to add to the discussion:FTP = File Transfer ProtocolHTTP = HyperText Transfer ProtocolFTP and HTTP are two standards that computers on the Internet use to communication with one another. One protocol is for transferring files, another is for transferring hypertext (i.e. web pages).

  13. So does anyone know of a way that I could have it set so that as long as I included the function into each link with the onclick() function, it wouldn't matter what page I was trying to change it too, it would just do it automatically?
    What is "str" for? Try passing the page href into the function:
    function changePage(page, str){	if (str.length==0)	{		document.getElementById("content").innerHTML="";		return;	}	xmlHttp=GetXmlHttpObject()	if (xmlHttp==null)	{		alert ("Your browser does not support AJAX!");		return;	}	// Rather than set this to a specific page, set it to the page that is	// passed in the parameters of the function:	var url = page;	url=url+"?q="+str;	url=url+"&sid="+Math.random();	xmlHttp.onreadystatechange=stateChanged;	xmlHttp.open("GET",url,true);	xmlHttp.send(null);}

    Then call it on the page like this:

    <a href="about.php" onclick="changePage(this.href, '???????'); return false;">About</a>

  14. Well, thanks jesh. I'll give that setup a try. I haven't heard any more from other users on the subject of XSLT vs. ASP.NET for display and manipulation of XML data, but hopefully some advice will come in. Thanks for your suggestion and code:)
    You might consider posting in the .NET forum. I am a .NET developer who doesn't know very much about XSLT but I happened to take a look at this forum yesterday. Perhaps one of the .NET developers here knows more about XSLT but also doesn't look at this forum much.
  15. If there's any other suggestions on things I could do, please suggest I'm always open for them.
    You could set up your links something like this:
    <a href="page2.html" onclick="loadContent('page2.html'); return false;">Go to page 2!</a>

    This way, if javascript is enabled on the browser, the loadContent function would run - this could be your AJAX loader code - and the "return false" will prevent the link from directing the users to page2. However, if javascript were disabled, the onclick would never fire and the page would simply go to page2.EDIT: To save some hassle, you could set up your links like this:

    <a href="page2.html" onclick="loadContent(this.href); return false;">Go to page 2!</a>

  16. I've seen it mentioned a number of times in this forum that the only reliable way to capture date input from users is to set up three fields: one for month, one for day, and one for year. Whether this fields are text fields or drop down menus would be up to you. Another alternative would be to find yourself a calendar control that you could put on your page that would allow a user to select a date from the calendar and have that calendar return the date to your script in a standardized format.

  17. what. One concern I'd have with this switch would be the ability to also transform that data into other formats, but the "PageHandlers" method you mentioned sounds interesting. Could you please point me in the right direction to some resources on that method?
    I, actually, meant to say "HttpHandlers" rather than "PageHandlers" - woops! You can set up an HttpHandler in your Web.config like so:
    <system.web>  <httpHandlers>	<add verb="POST,GET" path="*.xml" type="MyNamespace.MyXMLHttpHandler,MyDLLName" />  <httpHandlers></system.web>

    That would make it so that any request that came in for an XML file would be processed by the MyXMLHttpHandler class - the skeleton of that class would look something like this:

    using System;using System.Web;using System.Xml;namespace MyNamespace{	public class MyXMLHttpHandler : IHttpHandler	{		#region IHttpHandler Members		public bool IsReusable		{			get { return true; }		}		// This is the nitty-gritty of the handler.		public void ProcessRequest(HttpContext context)		{			// You can set the content-type of the request:			context.Response.ContentType = "text/xml"; // or perhaps "application/rss+xml"			// You can write directly to the output			context.Response.Write("<xml>some xml</xml>");			// Or, you can get access to the output stream and use an XmlWriter			XmlWriter writer = XmlWriter.Create(context.Response.OutputStream);		}		#endregion	}}

    I don't know if this is exactly what you're looking for, but knowledge of HttpHandlers (and HttpModules) can come in very handy.

  18. Something like this? (C#):

    // This is the Click handler for the first LinkButtonprotected void Button1_Click(object sender, EventArgs e){	// Create the LinkButton and set its properties	LinkButton button2 = new LinkButton();	button2.ID = "Button2";	button2.Text = "I am dynamic!";	button2.Click += new EventHandler(Button2_Click);	// Add the LinkButton to the control with an ID of "Label"	Label.Controls.Add(button2);}// This is the Click handler for the second LinkButton (that we added)protected void Button2_Click(object sender, EventArgs e){	Response.Write("You clicked the second, dynamically added, LinkButton!");}

  19. It looks like you already know about the setTimeout function, you can use that, in addition to a counter, to make the wheels spin. Just use the setTimeout to call the function over and over again in a loop:

    var spins = 20;function spin(){	var testImage1 = document.getElementById("drum1");	testImage1.src = imageSources[randomNumber()];	spins--;	if(spins > 0)	{		setTimeout("spin();", 50);	}}

  20. I wanted a completely dynamic site that contains the basic properties on one central page (MasterPage.master), and dynamic properties from data stored in XML documents. I also wanted to use XSLT to display the data, so that I can later easily transform the data into other formats, including PDF, RSS, etc. And finally, I wanted the transformation to be able to use code-behind for each of those pages.So I'm converting my entire site to store data in XML, and display it using XSLT with a ASP.NET transformation. I'm using the one central web.sitemap doc to store the entire site's navigation, so that I can use it from the Master page and the XSLT stylesheets. This setup allows one Master Page to process a page's static properties from the Web.sitemap doc by calling specific nodes from that sitemap into the page-specific XSLT stylesheet. So when I'm done, aboutus.xml will only call nodes in Web.sitemap that have an id of "arealinks", which will display a link to the "Area Links" page. I already had this setup with a central XML file called "internal_links.xml", but since I wanted to use the sitemap class throughout the site, I decided to try to figure out a way to do this using "Web.sitemap" instead.My current setup doesn't have a filter for the "id" attribute yet, so it's just displaying the entire sitemap in an unordered list.
    I probably would have written PageHandlers to deal with the different content types, but there are always more than one way to do something! I just want to give one more piece of advice - You can get the child nodes of any SiteMapNode like so:
    SiteMap.CurrentNode.ChildNodes

    If you are currently on "AboutUs", and "AboutUs" has a child node of "AreaLinks", then the return value of SiteMap.CurrentNode.ChildNodes is a one-element, one-dimensional array of SiteMapNodes which contains the SiteMapNode for "AreaLinks". This might be an easier way than parsing the entire XML file on your own and looking for a specific ID.OK, carry on the XSLT discussion. :)

  21. So, I've sort of been following this one. Why exactly are you using XSLT for this? Are you just trying to create a link from your sitemap file? It seems to me that it'd be much easier to do something like this:MasterPage.master:

    ...<asp:HyperLink id="SiteMapLink" runat="server />...

    MasterPage.master.vb:

    ...SiteMapLink.Text = SiteMap.CurrentNode.TitleSiteMapLink.NavigateUrl = SiteMap.CurrentNode.Url...

    Of course, I could be totally wrong - I didn't even know that the SiteMap class existed. :)EDIT: If you are trying to build the entire navigation, these links may help:http://msdn2.microsoft.com/en-us/library/s...datasource.aspxhttp://msdn2.microsoft.com/en-us/library/w...8fw(vs.80).aspxThe gist of the code is like so:MasterPage.master:

    <form id="form1" runat="server">			<asp:SiteMapDataSource				id="SiteMapDataSource1"				runat="server" />			<asp:TreeView				id="TreeView1"				runat="server"				DataSourceID="SiteMapDataSource1">			</asp:TreeView>		</form>

×
×
  • Create New...