I would like to display asterisk instead of no value in password field.
When I am setting up the field as type=text then I can see the plain text. When I set the type as password then I am getting blank field.
Is there a way to display the value as asterisks?
<input type="text" id="txtPwd" runat="server" />
This is the field I have.
Thanks in advance, Laziale
You can use the HTML5 placeholder attribute:
<input type="password" placeholder="●●●●●●●●●">
Example: http://jsfiddle.net/AJ2kn/
If you want the user's text input to be replaced by asterisks you need to use a password input—a text input just won't do it:
<input type="password" id="txtPwd" runat="server" />
However, the default value will be blank (this applies to text input as well). If you want to initialize this to a default value, you can do it like this:
<input type="password" value="dummy" id="txtPwd" runat="server" />
Note: I highly recommend not putting a users' password as the default value of a password field! It may compromise your users' password.
If you want to display some asterisks as placeholder text when the field is empty you can do that with with the placeholder attribute (again, this applies to text input as well):
<input type="password" placeholder="*****" id="txtPwd" runat="server" />
Related
I have a textbox which I would like bound with data from the logged in user, so that the user can't edit it. Would this need to be a label, or is there another way?
<p>Practice:
<input class="form-control" type="text" value="6666666 - Siya's Awesome world" readonly="readonly" id="txtName" />
</p>
Ps. I don't want the values entered as I did above. Your help is appreciated.
Use input like this :
<input readonly="readonly" disabled="disabled" class="text-box single-line readonly" id="field-id" name="field-name" />
Is it possible to get the value of the html input field (expiration) in C# after the user clicks outside of the field? And set the value from database to the html input field on page load or on refresh.
Here is my code:
<ext:Panel runat="server" Border="false">
<Content>
<label for="expiration"> Unknown date 2 </label>
<input id="expiration" type="text" placeholder="DD(uu)/MM(uu)/YY(uu)" class="masked" title="title" runat="server"
pattern="^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$|(uu\/([1-9]|0[1-9]|1[0-9]|2[0-9]|3[0-1])\/[0-9]{1,4})|(uu\/uu\/[0-9]{1,4})|(uu\/uu\/uu)"
data-valid-example="01/05/18">
</Content>
</ext:Panel>
It should normally be done with Request.Form["elementName"].
In this case, Request.Form["expiration"] to access its value, change your input to use name instead of id <input name="expiration" ... /> for it to work
I have a custom control which uses System.Windows.Form.Textbox as the underlying text box.
I want to change that type to type="number" however I don't see a way to do this.
The end goal is to have an input field which, when clicked on a smartphone browser, will give you only numeric keys to enter rather than the full keyboard.
It is possible to restrict the input to numbers only using JavaScript, but that is not what I want. I specifically need the keyboard to open with only numbers on it. If there is an alternative way to achieve this than setting type="number" then that should work as well.
You can add type="number" to an ASP.NET TextBox and it will render with that attribute.
<asp:TextBox ID="TextBox1" runat="server" type="number" />
Depending on ASP.NET version it will either render with both type="text" and type="number" (v2.0 - v3.5) or just type="number" (v4.0+).
If you wanted to add this conditionally in your code-behind, you could:
TextBox1.Attributes.Add("type", "number");
I have this code and I want it to transforms it to asp.net controls in label and literal ?
How?
` <input type="text" id="_Email" class="contact-form" name="Email" placeholder="Email address">`
That particular element would actually be a TextBox MSDN TextBox
It would look like this <asp:TextBox runat="server" ID="Email" CssClass="contact-form" />. this would then render <input type="text" id="_Email" class="contact-form" />
The Literal control doesn't produce an HTML element and allows you to add text/html to your page and not wrap it in any other HTML.
The Label control actually outputs a <span></span> and puts your Text in between it.
I am using asp.net C#
I am also using the jQuery UI Calendar control.
calendar control
It appears the calendar control wants to work with an input control with an ID of "datepicker".
<input type="text" id="datepicker" />
I want to use value of the input control in my code behind but seeing how it is not an asp.net control I am not sure how I can reference it in the code behind.
Does anyone know how to get the value of the input control in the code behind?
use
<input type="text" id="datepicker" name="datepicker" />
and in the code behind:
Request.Form["datepicker"]
In fact, Form property of Request is populated with form values.
Here you have to mention your form name which contains input tag
<input name="txtemail" id="txtemail" runat="server" type="text" class="cssspa" form="form"/>
in C#
string email = txtemail.Value.ToString();
now u can get data from textbox
If you want to use basic form pulling, you need to add a name attribute:
<input type="text" id="datepicker" name="datepicker" />
if(Page.IsPostBack)
{
string value = Request.Form["datepicker"];
}
Alternatively, you can mark is as an HtmlInputControl
<input type="text" id="datepicker" runat="server" />
System.Web.UI.HtmlControls.HtmlInputControl datepickerControl = this.FindControl("datepicker") as System.Web.UI.HtmlControls.HtmlInputControl;
if(datepickerControl != null)
string value = datepickerControl.Value;
You can access the value via the Request object like onof wrote, or you can turn every html tag into a server control by adding the attribute runat:
<input type="text" id="datepicker" runat="server" ClientIdMode="static" />
The attribute ClientIdMode="static" ensures that the tags ID is not changed by the ASP.NET runtime.
Then you can access the input by the autogenerated member datePicker.
Since you explicitly say code-behind, I assume you probably want to stay with the WebForms/Controls model? With clientidmode you can do that while also having a determinite id value for the calendar.
<asp:TextBox id="datepicker" ClientIDMode="Static" runat="server" />
Then you can interact directly with the control from the code-behind as normal.
But, the calendar control does not require a specific ID. You can initialize it with whatever ID you want
<asp:TextBox id="DateTextBox" runat="server" />
<script>
$(function() {
$( "#<%=DateTextBox.ClientID%>" ).datepicker();
});
</script>