Results 1 to 15 of 15

Thread: [Resolved] Basic problem

  1. #1

    Thread Starter
    Hyperactive Member naruponk's Avatar
    Join Date
    Feb 2004
    Location
    Some where in the world
    Posts
    423

    Resolved [Resolved] Basic problem

    Hi,

    i have 1 aspx named as "aspx1" i have created 1 textbox and 1 button.
    when i click a button how to pass a parameter in textbox to aspx2.aspx?

    I insert action=aspx2.aspx in <Form ....>.
    then i run and click the button i have seen no action from them.
    what's wrong? do i need to coding in codebehind file?

    Thanks for advance
    Last edited by naruponk; Apr 5th, 2005 at 05:46 AM.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Basic problem

    What does your <form> code look like? (Show more)

    How are you trying to access the values in page 2?

  3. #3

    Thread Starter
    Hyperactive Member naruponk's Avatar
    Join Date
    Feb 2004
    Location
    Some where in the world
    Posts
    423

    Talking Re: Basic problem

    <form id="Form1" method="post" runat="server" action="aspx2.aspx">

    I have set a session in code behind file of aspx1.aspx, i just want to test that how to pass a parameter to aspx2

    below is a code of event Page_Load on aspx2
    TextBox1.Text=Convert.ToString(Session["Test"]);

    Thanks for reply
    Last edited by naruponk; Apr 4th, 2005 at 05:45 AM.

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Basic problem

    Use Request.Form(), not Session().

  5. #5

    Thread Starter
    Hyperactive Member naruponk's Avatar
    Join Date
    Feb 2004
    Location
    Some where in the world
    Posts
    423

    Re: Basic problem

    Why when i press a submit button, in URL address is still aspx1.aspx?
    I have set action=aspx2 so URL address should shows aspx2.aspx

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Basic problem

    Depends. What sort of a submit button is it? Is it an <input type="submit"> or is it an asp:button with the text "Submit"?

  7. #7

    Thread Starter
    Hyperactive Member naruponk's Avatar
    Join Date
    Feb 2004
    Location
    Some where in the world
    Posts
    423

    Re: Basic problem

    currently using <input type="submit"> What should i do?
    how about asp:button?

  8. #8
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Basic problem

    Strange. Assuming that's the code you showed me, it shouldn't be like that.

    Post more code?

  9. #9

    Thread Starter
    Hyperactive Member naruponk's Avatar
    Join Date
    Feb 2004
    Location
    Some where in the world
    Posts
    423

    Talking Re: Basic problem

    Sorry, This is HTML Code

    <form id="Form1" method="post" runat="server" action="aspx2.aspx">
    <INPUT style="Z-INDEX: 101; LEFT: 304px; POSITION: absolute; TOP: 160px" type="submit" value="Submit"> </form>

  10. #10
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Basic problem

    Remove the runat="server" from the <form> tag.

  11. #11

    Thread Starter
    Hyperactive Member naruponk's Avatar
    Join Date
    Feb 2004
    Location
    Some where in the world
    Posts
    423

    Re: Basic problem

    Thanks it works!

    Below is code in Page_load event on aspx2

    if (Convert.ToString(Session["Test"])="Test")
    {
    TextBox1.Text="Test Successfully";
    }

    I got an error that "Cannot implicitly convert type string to bool"

  12. #12
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Basic problem

    PHP Code:
    if (Convert.ToString(Session["Test"])=="Test")
    {
    TextBox1.Text="Test Successfully";


  13. #13

    Thread Starter
    Hyperactive Member naruponk's Avatar
    Join Date
    Feb 2004
    Location
    Some where in the world
    Posts
    423

    Talking Re: Basic problem

    Got it thanks a lot mendhak
    What's advantage of runat=server tag?

  14. #14
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Basic problem

    When you use runat="server", it means you want it to be accessible in your codebehind.

    As a simple example, if you place a textbox on the page like so:

    Code:
    <input type="text" id="txtUserName" runat="server">
    You could then work with it in your .vb file like so:

    Code:
    Me.txtUserName.Text = "Something"

    You had the runat="server" attribute in your form tag, which meant it was a server side tag, and that was causing the problems. But to tell you the truth, I'm not sure why. It's often the case, gotta be careful with them runat="server" attributes!

  15. #15

    Thread Starter
    Hyperactive Member naruponk's Avatar
    Join Date
    Feb 2004
    Location
    Some where in the world
    Posts
    423

    Thumbs up Re: Basic problem

    Thanks a lot mendhak

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