hyperlink variable

Discussion in 'ASP .Net' started by Looch, Jun 4, 2007.

  1. Looch

    Looch Guest

    Something simple here (hopefully)...how can I append the text in a
    text box to a hyperlink? For example, I enter the string 'Printer223'.
    There is an Excel file with the same name that I want to open
    (Printer223.xls). Basically http://localhost/printers/whatever I put
    in the textbox.xls is what I'm after. Thanks.
     
    Looch, Jun 4, 2007
    #1
    1. Advertising

  2. On Jun 4, 10:12 pm, Looch <> wrote:
    > Something simple here (hopefully)...how can I append the text in a
    > text box to a hyperlink? For example, I enter the string 'Printer223'.
    > There is an Excel file with the same name that I want to open
    > (Printer223.xls). Basicallyhttp://localhost/printers/whateverI put
    > in the textbox.xls is what I'm after. Thanks.


    How do you want to open the file? Using a postback button?

    Response.Redirect("http://localhost/printers/" + TextBox1.Text +
    ".xls");
     
    Alexey Smirnov, Jun 4, 2007
    #2
    1. Advertising

  3. Looch

    Looch Guest

    On Jun 4, 4:18 pm, Alexey Smirnov <> wrote:
    > On Jun 4, 10:12 pm, Looch <> wrote:
    >
    > > Something simple here (hopefully)...how can I append the text in a
    > > text box to a hyperlink? For example, I enter the string 'Printer223'.
    > > There is an Excel file with the same name that I want to open
    > > (Printer223.xls). Basicallyhttp://localhost/printers/whateverIput
    > > in the textbox.xls is what I'm after. Thanks.

    >
    > How do you want to open the file? Using a postback button?
    >
    > Response.Redirect("http://localhost/printers/" + TextBox1.Text +
    > ".xls");


    Basically I just need to do this (using VBScript). The example below
    doesn't seem to work though.

    "http://amslpsvr1/consumables/OrderForms/" & strOrder &".xls"

    Here's the actual code (I'm a noob but I can get any Excel file to
    open this way!)

    <script language ='vbscript' >
    dim objExcel
    dim wb
    dim strOrder as string = me.txtOrderFrm.text
    Sub cmdOrderFrm_onclick()
    call OpenWorkbook("http://amslpsvr1/consumables/OrderForms/" &
    strOrder & ".xls")
    end sub
    sub OpenWorkbook(strLocation)
    set objExcel = CreateObject("Excel.Application")
    objExcel.Visible = true
    objExcel.Workbooks.Open (strLocation)
    objExcel.UserControl = true
    end sub
    </script>

    Thanks again for any help.
     
    Looch, Jun 4, 2007
    #3
  4. Looch wrote:
    > On Jun 4, 4:18 pm, Alexey Smirnov <> wrote:
    >> On Jun 4, 10:12 pm, Looch <> wrote:
    >>
    >>> Something simple here (hopefully)...how can I append the text in a
    >>> text box to a hyperlink? For example, I enter the string 'Printer223'.
    >>> There is an Excel file with the same name that I want to open
    >>> (Printer223.xls). Basicallyhttp://localhost/printers/whateverIput
    >>> in the textbox.xls is what I'm after. Thanks.

    >> How do you want to open the file? Using a postback button?
    >>
    >> Response.Redirect("http://localhost/printers/" + TextBox1.Text +
    >> ".xls");

    >
    > Basically I just need to do this (using VBScript). The example below
    > doesn't seem to work though.
    >
    > "http://amslpsvr1/consumables/OrderForms/" & strOrder &".xls"
    >
    > Here's the actual code (I'm a noob but I can get any Excel file to
    > open this way!)
    >
    > <script language ='vbscript' >
    > dim objExcel
    > dim wb
    > dim strOrder as string = me.txtOrderFrm.text
    > Sub cmdOrderFrm_onclick()
    > call OpenWorkbook("http://amslpsvr1/consumables/OrderForms/" &
    > strOrder & ".xls")
    > end sub
    > sub OpenWorkbook(strLocation)
    > set objExcel = CreateObject("Excel.Application")
    > objExcel.Visible = true
    > objExcel.Workbooks.Open (strLocation)
    > objExcel.UserControl = true
    > end sub
    > </script>
    >
    > Thanks again for any help.
    >


    First of all, you are in the wrong newsgroup. This has nothing to do
    with ASP.NET.

    Anyway, depending on where you put the script, you are either getting
    the value from the text box when the page is loading, or trying to get
    it before the text box even exists.

    If you want to get the value from the text box at the time of calling
    the cmdOrderForm_onclick subroutine, you have to put the code that gets
    the value inside the subroutine.

    Note also that "me" gets a different meaning if you put it inside the
    subroutine, as it then will refer to the control that you clicked rather
    than the window object.

    --
    Göran Andersson
    _____
    http://www.guffa.com
     
    =?ISO-8859-1?Q?G=F6ran_Andersson?=, Jun 5, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. davetichenor
    Replies:
    1
    Views:
    856
    Eliyahu Goldin
    Oct 30, 2006
  2. mfglinux
    Replies:
    11
    Views:
    725
    Roberto Bonvallet
    Sep 12, 2007
  3. Ken
    Replies:
    1
    Views:
    396
    Alvin Bruney
    Aug 16, 2003
  4. Dave
    Replies:
    0
    Views:
    969
  5. David Filmer
    Replies:
    19
    Views:
    257
    Kevin Collins
    May 21, 2004
Loading...

Share This Page