How to submit "<" and ">" ?

Discussion in 'C#' started by wacamoi, Mar 24, 2009.

  1. #1
    Do not want to use text form <input type="text" name="T1" size="20">
    example:
    thmlcode="<a href=""page1.html"">Page</a>"
    I want to use hidden form
    < input type"hidden" value="<%=thmlcode%>" name="h1" >

    question:
    why replace "<" and ">" are not working?
    thmlcode=replace(replace((thmlcode),">","&gt;"),"<","&lt;")
    when use <% response.write thmlcode %>


    please help


    Thanks,
    Regards,
     
    wacamoi, Mar 24, 2009 IP
  2. tihomir_wwf

    tihomir_wwf Active Member

    Messages:
    363
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    73
    #2
    I think that the reason is input's value="<%=thmlcode%>" is init before the code
    thmlcode=replace(replace((thmlcode),">","&gt;"),"<","&lt;") to be executed.

    My advice is:
    1. add runat="server" for the input:
    < input type"hidden" runat="server" id="_ID1" name="h1" >

    2. in Page_Load add
    _ID1.value = replace(replace((thmlcode),">","&gt;"),"<","&lt;")
    (you may also check for PostBack as well)
     
    tihomir_wwf, Mar 25, 2009 IP
    wacamoi likes this.
  3. wacamoi

    wacamoi Peon

    Messages:
    810
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks tihomir_wwf

    it helps

    An hour ago I also just found out <textarea> form can easy help to list the html code.
    I was wrong to use <input type="text" > form.

    Regards,
     
    wacamoi, Mar 25, 2009 IP