Results 1 to 3 of 3

Thread: how to recive the hyper link passed value in visual asp.net code behind

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Talking how to recive the hyper link passed value in visual asp.net code behind

    how to recive the hyper link passed value in visual studio asp.net code behind
    Hi experts. I have diffculty reciving hyper link passed value in visual studio.net code behind asp.net. I
    do not know how to recive this value and use it select statment.i be happy if some expert tell me
    how i can use visual studio.net 2003 wizard to create that code for me.Thank

  2. #2
    Frenzied Member <ABX's Avatar
    Join Date
    Jul 2002
    Location
    Canada eh...
    Posts
    1,622

    Re: how to recive the hyper link passed value in visual asp.net code behind

    If Visual Studio .Net could do all the work, do you think they would need programmers?

    To access a Query Variable...

    eg http://MyWebserver/MyApp/WebForm1.aspx?Msg=Hello+world

    The bold section of that url is called the Query String

    you can have multiple variables in here eg.

    http://MyWebserver/MyApp/WebForm1.aspx?Var1=Val1&Var2=Val2

    This url has two parameters, Var1 and Var2

    To get these values you would put this in your code behind....

    VB Code:
    1. Option Strict On
    2. Option Explicit On
    3.  
    4.  
    5. Public Class WebForm1
    6.     Inherits System.Web.UI.Page
    7.  
    8. #Region " Web Form Designer Generated Code "
    9.  
    10.     'This call is required by the Web Form Designer.
    11.     <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    12.  
    13.     End Sub
    14.  
    15.     'NOTE: The following placeholder declaration is required by the Web Form Designer.
    16.     'Do not delete or move it.
    17.     Private designerPlaceholderDeclaration As System.Object
    18.  
    19.     Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
    20.         'CODEGEN: This method call is required by the Web Form Designer
    21.         'Do not modify it using the code editor.
    22.         InitializeComponent()
    23.     End Sub
    24.  
    25. #End Region
    26.  
    27.     Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    28.         'Put user code to initialize the page here
    29.  
    30.         Dim Var1 As String = Request.QueryString.Item("Var1")
    31.         Dim Var2 As String = Request.QueryString.Item("Var2")
    32.  
    33.         'Check to make sure the variables were set
    34.         If IsNothing(Var1) Then
    35.             'Var1 was not Set
    36.             Var1 = "This Value was Not set!"
    37.         End If
    38.  
    39.         If IsNothing(Var2) Then
    40.             'Var2 was not set
    41.             Var2 = "This Value was Not set!"
    42.         End If
    43.  
    44.         'Display the Variables
    45.  
    46.         Response.Write("The Value of Var1 is: " & Var1 & " <br />") ' <br /> denotes a new line
    47.         Response.Write("The Value of Var2 is: " & Var2 & " <br />")
    48.  
    49.     End Sub
    50.  
    51. End Class
    Tips:
    • Google is your friend! Search before posting!
    • Name your thread appropriately... "I Need Help" doesn't cut it!
    • Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
    • Allways Include the Name and Line of the Exception (if one is occuring!)
    • If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)


    If you think I was helpful, rate my post
    IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Arrow Re: how to recive the hyper link passed value in visual asp.net code behind

    Many thanks to your reply. your code is very helpfull. if i want add a hyper link to datagrid which holds a primary key of perticuler record how i can accomplish that part. i want use the passed value in next page using your method and use it in select statement.Thanks
    Last edited by tony007; May 21st, 2005 at 05:03 AM.

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