A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [RESOLVED] ASP.net Case statement...

  1. #1
    FK's Official War Driver wiReZ's Avatar
    Join Date
    Jun 2002
    Location
    wireless
    Posts
    615

    [RESOLVED] ASP.net Case statement...

    Okay, fair warning: I'm not much of a programmer. Anyways, I had a quick question for someone who knows how to make this case statement I have truncated into something smaller... here's what I got.

    Code:
    <%@ Page Language="C#" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
    <%@ import Namespace="System" %>
    <%@ import Namespace="System.IO" %><script runat="server">
    	private void Page_Load (object sender, System.EventArgs e){
    		string filePath;
    		switch(Request.QueryString["article"]){
    			case "001":
    				filePath = "/news/001.aspx";
    				break;
    			case "002":
    				filePath = "/news/002.aspx";
    				break;
    			case "003":
    				filePath = "/news/003.aspx";
    				break;
    			case "004":
    				filePath = "/news/004.aspx";
    				break;
    			case "005":
    				filePath = "/news/005.aspx";
    				break;
    			default:
    				filePath = "/news/home.aspx";
    				break;
    		}
    		try{
    			using (StreamReader sr = new StreamReader(Server.MapPath(filePath))){
    				newsContainer.Text += sr.ReadToEnd();
    			}
    		}
    		catch (Exception ex){
    			newsContainer.Text = "Sorry, there has been an error loading this page.";
    		}
    	}
    </script>
    Basically, instead of writing the case statement numbers over and over, whats the easier way?
    Last edited by wiReZ; 04-19-2006 at 01:23 PM.
    My current rig: AMD Athlon64 3500+(Winchester Core) MSI K8N Neo2 Platinum - 1GB
    (2x512MB) Kingston HyperX DDR333 BH5 - ATI All-In-Wonder 9800 Pro 128mb - SB Audigy 2
    WD 80GB 7200RPM 8MB - WD 250GB 7200RPM 8MB - MAX 120GB 7200RPM 8MB - Dell 2001FP 20.1 LCD

  2. #2
    FK's Official War Driver wiReZ's Avatar
    Join Date
    Jun 2002
    Location
    wireless
    Posts
    615
    bump? help?
    My current rig: AMD Athlon64 3500+(Winchester Core) MSI K8N Neo2 Platinum - 1GB
    (2x512MB) Kingston HyperX DDR333 BH5 - ATI All-In-Wonder 9800 Pro 128mb - SB Audigy 2
    WD 80GB 7200RPM 8MB - WD 250GB 7200RPM 8MB - MAX 120GB 7200RPM 8MB - Dell 2001FP 20.1 LCD

  3. #3
    FK's Official War Driver wiReZ's Avatar
    Join Date
    Jun 2002
    Location
    wireless
    Posts
    615
    K, I figured it out... here's the correct syntax

    Code:
    <%@ Page Language="C#" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
    <%@ import Namespace="System" %>
    <%@ import Namespace="System.IO" %><script runat="server">
    private void Page_Load (object sender, System.EventArgs e){
    	string filePath;
    	filePath = "/news/" + Request.QueryString["article"] + ".aspx";
    	try {
    		using (StreamReader sr = new StreamReader(Server.MapPath(filePath))){
    			newsContainer.Text += sr.ReadToEnd();
    		}
    	}
    	catch (Exception ex){
    			newsContainer.Text = "<span>Sorry, there has been an error loading this page.</span>";
    	}
    }
    </script>
    My current rig: AMD Athlon64 3500+(Winchester Core) MSI K8N Neo2 Platinum - 1GB
    (2x512MB) Kingston HyperX DDR333 BH5 - ATI All-In-Wonder 9800 Pro 128mb - SB Audigy 2
    WD 80GB 7200RPM 8MB - WD 250GB 7200RPM 8MB - MAX 120GB 7200RPM 8MB - Dell 2001FP 20.1 LCD

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center