Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Hidden field?

    Hi,

    I have WebPage1 which has a link to go to WebPage2. This link passes a value
    to WebPage2. In the page_load event I get this value using
    Request.QueryString and put it in a public data member of WebPage 2.
    WebPage2 has a button on it and when this button is clicked the page is
    posted back to the server.

    My question is when the page is posted back to the server do I still have
    the value that was passed from WebPage1 (Which I had stored in the public
    datamember). If it's not then, I guess I will have to use hidden box and if
    that's the case then, what is the syntax for creating a hidden text box?

    Also, if this WebPage1 creates a datatable in dataset then, can this
    datatable be used in WebPage2. If yes then, how?

    Thanks

    Yatin


    Yatin Bhuta Guest

  2. Similar Questions and Discussions

    1. from text field to hidden field
      Can you collect data from a text field and store it into a hidden field all one the same asp form so that on submit the value of the hidden field is...
    2. Set Text of Hidden Field
      It sure would be great if Set Text Of... supported hidden fields as well as Text, Password and TextArea. I thought I could add this support by...
    3. Setting hidden field value eq to a form field value.
      Ok guys help a dumb blond out. I need to pass the value of a form field to two different file fields. Here is an example of what I have; <form...
    4. inserting into db from hidden field
      On Tue, 8 Jul 2003 16:44:16 +0200, "awebb" <andywebb25@hotmail.com> wrote: I'm curious why you are using an entire table cell for a hidden...
    5. hidden field
      hi! Is it possible to have a textbox web server control as hidden ? and how ? When I use the visible property the textbox isn't rendered.
  3. #2

    Default Hidden field?

    >-----Original Message-----
    >Hi,
    >
    >I have WebPage1 which has a link to go to WebPage2. This
    link passes a value
    >to WebPage2. In the page_load event I get this value using
    >Request.QueryString and put it in a public data member of
    WebPage 2.
    >WebPage2 has a button on it and when this button is
    clicked the page is
    >posted back to the server.
    >
    >My question is when the page is posted back to the server
    do I still have
    >the value that was passed from WebPage1 (Which I had
    stored in the public
    >datamember).
    No. You only have it when the page first loads. When you
    post back a new instance of your page is created so you
    loose the value in your property.

    If it's not then, I guess I will have to use hidden box
    and if
    >that's the case then, what is the syntax for creating a
    hidden text box?

    <asp:textbox id="txtHidden" visible="false"
    runat="server" />
    >
    >Also, if this WebPage1 creates a datatable in dataset
    then, can this
    >datatable be used in WebPage2. If yes then, how?
    This is possible. You could put the datatable in the pages
    Context.Items collection, and do a Server.Transfer to
    WebPage2.

    However you may want to rethink your design, it's not a
    good idea to be passing tables around in the request.
    >
    >Thanks
    >
    >Yatin
    >
    >
    >.
    >
    Lachlan James Guest

  4. #3

    Default Re: Hidden field?

    If you need to persist the data between page postback you can also put
    it in the ViewState.

    Natty Gur, CTO
    Dao2Com Ltd.
    34th Elkalay st. Raanana
    Israel , 43000
    Phone Numbers:
    Office: +972-(0)9-7740261
    Fax: +972-(0)9-7740261
    Mobile: +972-(0)58-888377


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur Guest

  5. #4

    Default Re: Hidden field?

    First question:
    Hidden Field: When your WebPage2 is loading, in the pageload event
    write this line of code to register a hidden variable and set a value
    for it.
    RegisterHiddenField("VariableName", VariableValue)
    During the post back you can get back the value using
    Request.Form("VariableName")

    Second question:
    After the code behind page is completed processing all your variables,
    objects created in the page will be no longer available for you to
    use. Because they have only Page level scope. If you want to create an
    object in one page and want to use that in another page, there are
    many ways to do it. You store that object in Session or Application,
    Cache or Static(shared) variable, then you can access them in other
    pages. Application and Cache also will work similar to static
    variables and you will have only one instance of them for all the
    users. If you want to have different objects for different users, you
    need to use a session variable.

    "Yatin Bhuta" <ybuhta@comcast.net> wrote in message news:<DfDXa.66555$uu5.6110@sccrnsc04>...
    > Hi,
    >
    > I have WebPage1 which has a link to go to WebPage2. This link passes a value
    > to WebPage2. In the page_load event I get this value using
    > Request.QueryString and put it in a public data member of WebPage 2.
    > WebPage2 has a button on it and when this button is clicked the page is
    > posted back to the server.
    >
    > My question is when the page is posted back to the server do I still have
    > the value that was passed from WebPage1 (Which I had stored in the public
    > datamember). If it's not then, I guess I will have to use hidden box and if
    > that's the case then, what is the syntax for creating a hidden text box?
    >
    > Also, if this WebPage1 creates a datatable in dataset then, can this
    > datatable be used in WebPage2. If yes then, how?
    >
    > Thanks
    >
    > Yatin
    Ram Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139