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. Advertisements

  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
     
    Karl Seguin, Jan 21, 2005
    #2
    1. Advertisements

  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. ?
    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
     
    Bob Barrows [MVP], Jan 21, 2005
    #4
  5. Newbie

    Newbie Guest

    Yes, it's work, Bob.

    Thks a lot.

    rgds,
    andy

     
    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
     
    Karl Seguin, Jan 24, 2005
    #6
  7. I'm still in the learning phase myself. My mind is still firmly entrenched
    in the classic ASP way of doing things.

    Bob Barrows
     
    Bob Barrows [MVP], Jan 24, 2005
    #7
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.