C# School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a C# Expert!

Join 300,406 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,613 people online right now. Registration is fast and FREE... Join Now!




how to get the hyper link and redirecting into a blank page

 

how to get the hyper link and redirecting into a blank page

shyam548

29 Jun, 2009 - 07:38 PM
Post #1

New D.I.C Head
*

Joined: 29 Jun, 2009
Posts: 3

Hello

actually...i am trying to create a hyperlink of a text file retrieving the file from the database.....

after creating a hyperlink i have to navigate to the blank page to see the text document....

i have tried...but i am a fresher and beginner to c#

CODE
SqlCommand cmd = new SqlCommand("GetCount", con);
            SqlCommand cmd1 = new SqlCommand("Getlocation", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd1.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@Description", dr[0].ToString());
            cmd1.Parameters.AddWithValue("@Description", dr[0].ToString());
            DataSet ds = new DataSet();
            DataSet ds1 = new DataSet();
            SqlDataAdapter da1 = new SqlDataAdapter(cmd1);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            da1.Fill(ds1);
            da.Fill(ds);
            string strd = ds1.Tables[0].Rows[0][0].ToString();
            string strv = ds.Tables[0].Rows[0][0].ToString();
            strPath = strd;
            int count = int.Parse(strv);
            countf = countf + count;
            Literal lit = new Literal();
            lit.Text = dr[0].ToString() + "<br>";
            Panel1.Controls.Add(lit);
            HyperLink hpk = new HyperLink();
            hpk.Text = strPath + ".txt";
            hpk.NavigateUrl = "file:///"+strPath + ".txt";
            //lit1.Text = "<asp:HyperLink  Text = " + strPath + "  ></asp:HyperLink>";
            Panel1.Controls.Add(hpk);
            


i tried but....the link appears but it doesnot link to other page or doesnot show up anything....i need help

User is offlineProfile CardPM
+Quote Post


JayFCox

RE: How To Get The Hyper Link And Redirecting Into A Blank Page

30 Jun, 2009 - 06:08 PM
Post #2

New D.I.C Head
*

Joined: 31 May, 2009
Posts: 41



Thanked: 5 times
My Contributions
CODE

            hpk.NavigateUrl = "file:///"+strPath + ".txt";



(Scratches head) why are you linking to a local file?
User is offlineProfile CardPM
+Quote Post

shyam548

RE: How To Get The Hyper Link And Redirecting Into A Blank Page

30 Jun, 2009 - 06:16 PM
Post #3

New D.I.C Head
*

Joined: 29 Jun, 2009
Posts: 3

QUOTE(JayFCox @ 30 Jun, 2009 - 06:08 PM) *

CODE

            hpk.NavigateUrl = "file:///"+strPath + ".txt";



(Scratches head) why are you linking to a local file?



my text file is in the server so i am linking it to the local file......here the problem is ....i cant open the file though it is hyperlinked.....it doesnot show anything......

User is offlineProfile CardPM
+Quote Post

JayFCox

RE: How To Get The Hyper Link And Redirecting Into A Blank Page

1 Jul, 2009 - 04:38 AM
Post #4

New D.I.C Head
*

Joined: 31 May, 2009
Posts: 41



Thanked: 5 times
My Contributions
QUOTE(shyam548 @ 30 Jun, 2009 - 06:16 PM) *

QUOTE(JayFCox @ 30 Jun, 2009 - 06:08 PM) *

CODE

            hpk.NavigateUrl = "file:///"+strPath + ".txt";



(Scratches head) why are you linking to a local file?



my text file is in the server so i am linking it to the local file......here the problem is ....i cant open the file though it is hyperlinked.....it doesnot show anything......


There's probably a good reason for this. I get the feeling this kind of action (linking to a local file for utilization) violates some kind of security protocol. You may be able to link to it but I doubt the browser would respect any click action on it. The reason being you just don't want to be able to open or execute any arbitrary file on your machine by linking to a possible path on you machine from an aribitrary web page. But that's just my hypothesis, not conclusive.

Actually, wikipedia seems to agree http://en.wikipedia.org/wiki/File_URI_scheme
(According to the page) some browsers do allow such actions, but Firefox doesn't do it, and neither do IE7 onwards.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 10:44PM

Live C# Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month