assigning variable's value to htmlinput

Discussion in 'ASP .Net' started by Newbie, Jan 21, 2005.

  1. Newbie

    Newbie Guest

    hi all,

    in a webform's codebehind, i have a variable (ie: nTotal). and in UI i have
    a hidden htmlinput (ie: fld1).
    Q: how to assign the value of nTotal to now i want to assign the value of
    nTotal to fld1?

    many thanks in advance,
    andy
     
    Newbie, Jan 21, 2005
    #1
    1. Advertising

  2. Newbie

    Karl Seguin Guest

    Andy:
    You can't. This is a security feature of HTML and has nothing to do with
    ASP.Net. html input values are read only. If they weren't, anyone could
    put a hidden html input field and set the value like "c:\passwords.txt" and
    when the user clicked any button they'd have their passworsd.txt file
    uploaded without ever knowing it.

    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/


    "Newbie" <> wrote in message
    news:ue2R$m%23$...
    > hi all,
    >
    > in a webform's codebehind, i have a variable (ie: nTotal). and in UI i

    have
    > a hidden htmlinput (ie: fld1).
    > Q: how to assign the value of nTotal to now i want to assign the value of
    > nTotal to fld1?
    >
    > many thanks in advance,
    > andy
    >
    >
     
    Karl Seguin, Jan 21, 2005
    #2
    1. Advertising

  3. Newbie

    Newbie Guest

    hi all,

    (a little correction to mistyped)

    in a webform's codebehind, i have a variable (ie: nTotal). and in UI i have
    a hidden htmlinput (ie: fld1).
    Q: how to assign the value of nTotal to fld1?

    many thanks in advance,
    andy
     
    Newbie, Jan 21, 2005
    #3
  4. Karl Seguin wrote:
    > Andy:
    > You can't. This is a security feature of HTML and has nothing to do
    > with ASP.Net. html input values are read only. If they weren't,
    > anyone could put a hidden html input field and set the value like
    > "c:\passwords.txt" and when the user clicked any button they'd have
    > their passworsd.txt file uploaded without ever knowing it.
    >

    ?
    CMIIW, but that's only true if the input's type is file, and the form's
    ENCTYPE attribute is "multipart/form-data".

    You need to response.write the variable's value into the html:

    <input type="hidden" value="<%=nTotal%>">

    Bob Barrows
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
     
    Bob Barrows [MVP], Jan 21, 2005
    #4
  5. Newbie

    Newbie Guest

    Yes, it's work, Bob.

    Thks a lot.

    rgds,
    andy

    "Bob Barrows [MVP]" <> wrote in message
    news:#miGw6$$...
    > Karl Seguin wrote:
    > > Andy:
    > > You can't. This is a security feature of HTML and has nothing to do
    > > with ASP.Net. html input values are read only. If they weren't,
    > > anyone could put a hidden html input field and set the value like
    > > "c:\passwords.txt" and when the user clicked any button they'd have
    > > their passworsd.txt file uploaded without ever knowing it.
    > >

    > ?
    > CMIIW, but that's only true if the input's type is file, and the form's
    > ENCTYPE attribute is "multipart/form-data".
    >
    > You need to response.write the variable's value into the html:
    >
    > <input type="hidden" value="<%=nTotal%>">
    >
    > Bob Barrows
    > --
    > Microsoft MVP -- ASP/ASP.NET
    > Please reply to the newsgroup. The email account listed in my From
    > header is my spam trap, so I don't check it very often. You will get a
    > quicker response by posting to the newsgroup.
    >
    >
     
    Newbie, Jan 24, 2005
    #5
  6. Newbie

    Karl Seguin Guest

    doh...for some reason I read that it was an HtmlFileInput control :)

    anyways, why use the old ASP method of Response.WRite? Declare it as a
    webcontrol and set the value programatically.

    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/


    "Bob Barrows [MVP]" <> wrote in message
    news:%23miGw6$$...
    > Karl Seguin wrote:
    > > Andy:
    > > You can't. This is a security feature of HTML and has nothing to do
    > > with ASP.Net. html input values are read only. If they weren't,
    > > anyone could put a hidden html input field and set the value like
    > > "c:\passwords.txt" and when the user clicked any button they'd have
    > > their passworsd.txt file uploaded without ever knowing it.
    > >

    > ?
    > CMIIW, but that's only true if the input's type is file, and the form's
    > ENCTYPE attribute is "multipart/form-data".
    >
    > You need to response.write the variable's value into the html:
    >
    > <input type="hidden" value="<%=nTotal%>">
    >
    > Bob Barrows
    > --
    > Microsoft MVP -- ASP/ASP.NET
    > Please reply to the newsgroup. The email account listed in my From
    > header is my spam trap, so I don't check it very often. You will get a
    > quicker response by posting to the newsgroup.
    >
    >
     
    Karl Seguin, Jan 24, 2005
    #6
  7. Karl Seguin wrote:
    > doh...for some reason I read that it was an HtmlFileInput control :)
    >
    > anyways, why use the old ASP method of Response.WRite? Declare it as
    > a webcontrol and set the value programatically.
    >


    I'm still in the learning phase myself. My mind is still firmly entrenched
    in the classic ASP way of doing things.

    Bob Barrows
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
     
    Bob Barrows [MVP], Jan 24, 2005
    #7
    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. Sean Patterson

    HtmlInput "Security" Issue?

    Sean Patterson, Apr 29, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    364
    Sean Patterson
    Apr 29, 2004
  2. Mark Rae
    Replies:
    12
    Views:
    650
    Mark Rae
    Mar 8, 2005
  3. Replies:
    0
    Views:
    403
  4. Anita C

    htmlinput-checkbox

    Anita C, Aug 25, 2003, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    116
    Rohit
    Aug 26, 2003
  5. Sara
    Replies:
    1
    Views:
    295
    Patrice
    Aug 8, 2005
Loading...

Share This Page