简体   繁体   中英

How do I read value from code behind on html page? Or any better way of doing that?

Solution: I end up creatting a WCF that accepts a get/post request, then place JQuery within the html page that retrieves the value and hands it off to the web service

I have a html page like below where I will be doing posting to a web site for registrations and my credentials are not suppose to show on the client side.

My question is how/what is the best way of reading the values from code behind or web service or any other way ?

    <FORM NAME="web_form" ACTION="https://website.com/registration.php" METHOD="POST">
        <TABLE WIDTH=961 BORDER=0 CELLPADDING=2 CELLSPACING=0> 
            <TR>
                <TH WIDTH=380>
                    <P ALIGN=RIGHT><i>Encrypted Username:</i> 
                    </P>
                </TH>
                <TD WIDTH=573>
                    <P><A NAME="username"></A><INPUT TYPE=TEXT NAME="username" VALUE="HOW TO GET VALUE???" SIZE=20 STYLE="width: 1.69in; height: 0.23in"></P>
                </TD>
            </TR>
            <TR>

..............
.................

Switch the input box in to an ASP control?

<asp:TextBox runat="server" ID="username" ClientIDMode="Static" />

Then in your code behind:

this.username.Text

There's probably a little more that we need to know to make a perfect suggestion, but there's tons of different ways that you could do this.

If you have access to the registration page -- which would be ideal -- you could send a base64encoded string via the URL or via hidden input in the form field posted on submit to the reg page and then base64 decode it before passing in. Similarly, you could salt the value with any number of different methods and "un-salt" it at the application.

Merely hiding it in a hidden input field probably won't suffice here as that code is certainly available on a view source, unless the data inside it is sufficiently obfuscated.

There are javascript obfuscators that will do a sufficient job, but they'll be unavailable if the user has javascript turned off. It won't affect 99% of the users out there, but it is something to think about.

Perhaps you could set this up as a dynamic page (not HTML) and set some sort of a constant? Perhaps a session variable that you then call in at the registration page?

您可以使用JavaScript在客户端进行操作:

INPUT TYPE="text" NAME="username" VALUE="some value" onclick="CopyValue()" /> function CopyValue() { var myValue = document.getElementById('username').value;
}

Not an answer but just a suggestion. In HTML always try to keep your values in quotes. Always a good programming practice. Will definitely help you if you are trying to move from HTML to XHTML or XML. Good Luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM