473,406 Members | 2,345 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Bug: System.Web.UI.HtmlControls.HtmlInputControl - Type = Password

Hello NG,

i think i found a bug. I've programmed an application that uses a HTML Input
textbox. The HTML type is "Password". The content is marked with "*". Thats
fine. I change the runat tag to server. Now i try to fill the control value
an nothing happens. try example at bottom.

i tried some workaround but even with the asp:textbox it doesen't work. i
need this peace of code for a loginscreen where i want to fill the password
from a local cookie, so the user is still able to change the login for a
different user.

Any comment?

Bye Marco

<%@ Page Language="C#" AutoEventWireup="True" %>

<html>
<head>

<script language="C#" runat="server">

void Page_Load(object sender, EventArgs e)
{

if (Page.IsPostBack)
{
Span1.InnerHtml="Hidden value: <b>" + HiddenValue.Value +
"</b>";
}
}

void SubmitBtn_Click(object sender, EventArgs e)
{
HiddenValue.Value=StringContents.Value;
}

</script>

</head>

<body>

<form runat=server>

<h3>HtmlInputHidden Sample</h3>

<input id="HiddenValue"
type=password
value="Initial Value"
runat=server>

Enter a string:

<input id="StringContents"
type=text
size=40
runat=server>

<p>

<input type=submit
value="Enter"
OnServerClick="SubmitBtn_Click"
runat=server>

<p>

<span id=Span1 runat=server>
This label will display the previously entered string.
</span>

</form>

</body>
</html>
Nov 18 '05 #1
3 1750
Try this one:
txtPassword.attributes.add("value", [password])

But it mean that you show your password to any one(because value is shown in
html view source)
HTH

"Marco Scheel" <at****@visual-evolution.de> wrote in message
news:ul**************@tk2msftngp13.phx.gbl...
Hello NG,

i think i found a bug. I've programmed an application that uses a HTML Input textbox. The HTML type is "Password". The content is marked with "*". Thats fine. I change the runat tag to server. Now i try to fill the control value an nothing happens. try example at bottom.

i tried some workaround but even with the asp:textbox it doesen't work. i
need this peace of code for a loginscreen where i want to fill the password from a local cookie, so the user is still able to change the login for a
different user.

Any comment?

Bye Marco

<%@ Page Language="C#" AutoEventWireup="True" %>

<html>
<head>

<script language="C#" runat="server">

void Page_Load(object sender, EventArgs e)
{

if (Page.IsPostBack)
{
Span1.InnerHtml="Hidden value: <b>" + HiddenValue.Value +
"</b>";
}
}

void SubmitBtn_Click(object sender, EventArgs e)
{
HiddenValue.Value=StringContents.Value;
}

</script>

</head>

<body>

<form runat=server>

<h3>HtmlInputHidden Sample</h3>

<input id="HiddenValue"
type=password
value="Initial Value"
runat=server>

Enter a string:

<input id="StringContents"
type=text
size=40
runat=server>

<p>

<input type=submit
value="Enter"
OnServerClick="SubmitBtn_Click"
runat=server>

<p>

<span id=Span1 runat=server>
This label will display the previously entered string.
</span>

</form>

</body>
</html>

Nov 18 '05 #2
Anatoly wrote:
Try this one:
txtPassword.attributes.add("value", [password]) This doesen't work. I've tried it. Only workaround is to get rid of the
runat server and use something like that:
<input type="password" value="<%= passwordValue %> name="userPass">
Retrieve the value with request.form.
But it mean that you show your password to any one(because value is
shown in html view source)
HTH

I know that. But if the user is willing to store the password in a cookie
(it is his choice, we don't force him) then it its ok to write the password
in the html because we use https for transport. Even if i retriev the value
from the cookie, i have to fill someting in the form field so the user
thinks the password is allready typed in. i could use asteriks... but if
hier tries to log in as another user (then stored in the cookie) the text
would be shown in cleartext... that is bad.

But thanx for you comment.

Bye Marco
Nov 18 '05 #3
Hi Marco,

If the runat property of the html password field was set to "server",
ASP.NET will ignore its value for the consideration of security.

If you want to set the value of a password filed that runs at server from
code-behind, we should emit a block of client-side script via the
RegisterStartupScript method. For example,

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
String pwd = "my password";
String scriptString = "<script language=JavaScript>\n";
scriptString += "function Page_Load()\n";
scriptString += "{\n";
scriptString += "document.getElementById('password1').value='" + pwd +
"';\n";
scriptString += "}\n";
scriptString += "</script>\n";

if(!this.IsStartupScriptRegistered("Startup"))
this.RegisterStartupScript("Startup", scriptString);

}

Then, to call the client-script above, add the onload property to the
<body> tag in HTML source.

<body MS_POSITIONING="GridLayout" onload="return Page_Load();">

Please let me know if it makes sense.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Just D. | last post by:
All, Did anybody see this strange effect? The web application is written in C#, ASP.NET, SQL, T-SQL, etc. A pretty usual stuff, complicated enough, but works fine until... Here is a question....
0
by: Mark Miller | last post by:
I have a datagrid where I need to display a list of radiobuttons for each row. Unfortunatly, RadioButtonList does not meet my requirements because I need some flexibilty for formatting. So, I added...
3
by: NGM | last post by:
Hello All, From one week rather developing any code i have been discovering BUGS in asp.net, Please help me out on this! I have class say 'Handler' which inherits System.Web.UI.Page, and i...
10
by: tshad | last post by:
I have a problem setting the background color of textbox on the fly. I tried using: applicantID.backcolor = "F6F6F6" and applicantID.backcolor = "#F6F6F6"
8
by: David Cameron | last post by:
I noticed that using an HTMLInputRadioButton and specifying a value to be an empty string (""), this is overridden by ASP.Net which set the value of the control to be the same as the ID of the...
6
by: heybrakywacky | last post by:
After hours of pulling my hair out on this one, I've finally realized that the problem I'm having in my code is due to behavior that is not at all expected. Using ASP.NET 1.1.4322.2032, I'm...
2
by: Sean Carey | last post by:
I converted a C# Upload app to VB.NET and am down to one error and was hoping someone could help me with te error. I would greatly appreciate help from anyone. Here is the error: ...
56
by: Rob Dob | last post by:
VS2005 is a PIECE of Garbage and is bug Ridden, I wonder how many others feel the same, I am so sorry that I have moved away from VS2003, VS2005 is unstable, and half the stuff doesn't work, ...
8
by: =?Utf-8?B?UiBSZXllcw==?= | last post by:
I have a public class called Database.cs. It has public static functions and I call them from ProjectA. The code looks something like: int intConnectionSuccessful = Database.ConnectToDatabase();...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.