Browser Remember password set username to other textboxes also - c#

When I use browser remembered password, after login, some textboxes in my forms shows username.
I am confused, how it works?
Please provide solution to avoid this problem?

Set TextBox property TextMode as Password
or try this
TextBox1.Attributes.Add("autocomplete", "off");
<form id="Form1" method="post" runat="server" autocomplete="off"></form>
Using Javascript you can also delete history of textbox
function disableautocompletion(id){
var passwordControl = document.getElementById(id);
passwordControl.setAttribute("autocomplete", "off");
}
Try:
<asp:TextBox ID="MyTextBox" AutoCompleteType="Disabled" runat="server" />
this renders as:
<input id="MyTextBox" name="MyTextBox" type="text" autocomplete="off" />
for more info MSDN for autocomplete
And this is helpful link

Related

ASP.net - How to reference a text box in the code behind?

This is highly likely to be a stupid question, so my apologies. But I can't seem to find an answer anywhere. I am brand new to ASP.net and I'm using C# for the code behind (I have experience with C# from a WinForms project I did, also in Visual Studio)
I have a page, a register for an account page, on the website and I want to be able to access the TextBox that contains email and password etc. I thought it would be something like textboxname.getText() or similar to get what the user has typed into that box when they press submit (clicking submit is my Event) but I don't now how to make it recognize that textboxname is the ID.
For example:
<input type="email" class="form-control" placeholder="Enter Email" id="email"/>
My email TextBox has an ID of 'email'. In code, if I try to type email.getText(), it does not recognize that email refers to that TextBox. If I could even get it to recognize the ID, I could figure out the rest from there.
Thank you for listening to my excessive beginner ranting! If any extra details are necessary I'll add them, just ask.
Resolved! - For some reason it did not generate a designer for my pages when i created the web forms, so i regenerated the design.cs and it is working! :D Thanks for help anyway!
Be sure your markup is correct on front end - even if you are a space off between quotes it can mess things up.
<asp:TextBox id="email" runat="server" Text="Email" />
email.Text = "your text here";
You should use email.Text; (since it's a property, no a method) instead of email.getText(). Also make sure your control has runat property equals to "server" on HTML.
On your page
you have to declare a form with a submit button and within this form you can have your textbox.
<form id="myForm" runat="server">
<asp:TextBox id="TB_Email" placeholder="Enter Email" runat="server"></asp:TextBox>
<asp:Button ID="Btn_Submit" runat="server" Text="Submit" OnClick="Btn_Submit_Click" />
</form>
Code behind
protected void Btn_Submit_Click(object sender, EventArgs e)
{
// here you can access the value of your email-textbox
String email = TB_Email.Text;
}
Use:
<input type="email" class="form-control" placeholder="Enter Email" id="email" runat="server"/>
or alternatively,
<asp:TextBox id="email" runat="server"/> /*Add any other attributes you need*/
In the code behind:
email.Text="your text here";
Without runat="server" attribute, your control is just a HTML control and hence you cannot access it from the server side code(code behind).

Using Telerik rad captcha with asp.net

I am new to telerik controls.
I have a aspx form with HTML controls on it. Data will be submitted using post method. I want to use Telerik Captcha on my page.
I have added following code on my aspx page :
<form id="frmYourDetails" runat="server" method="post" action="save.aspx">
Number: <input type="text" name="CustomerNumber" id="CustomerNumber" pattern="\d{2}-(?:\d{4}-){3}\d{1}" maxlength="19" title="xx-xxxx-xxxx-xxxx-x" required >
Name : <input type="text" name ="CustomerName" id ="CustomerName" required >
<telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
<telerik:RadCaptcha ID="RadCaptcha1" Runat="server" ErrorMessage="The code you entered is not valid." Display="Dynamic"></telerik:RadCaptcha>
<button type="submit" id="btnSubmit">Save</button>
</form>
How do i validate if user has entered correct value in textbox that comes with RadCaptcha? I want this validation on client side if possible.
Captchas do not validate on the client, only on the sever for security reasons (if they did on the client they would be next to useless).
Call the Validate() method of the captcha or the page and check the IsValid property of the captcha.
You can see more options by using the RadCaptcha events in this demo http://demos.telerik.com/aspnet-ajax/captcha/examples/serversideevents/defaultcs.aspx

prevent Asp.NET button from submitting form

So, I have a Paypal form that worked wonders. However, I now need to add a coupon field, where someone can enter a code, and get a reduction based on whatever the backend replies.
This all works wonderfully, but I've ran into an issue when adding the option to know before checking out whether your code is valid or not. Currently, my form (once simplified) looks like this :
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"
id="payPalForm" runat="server">
<asp:TextBox runat="server" ID="txtCode" />
<asp:Button Text="Validate" OnClick="ValidateDiscount" runat="server" />
<asp:Label ID="txtDesc" runat="server" />
<input type="submit" name="Submit" value="Pay up!" />
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="upload" value="1" />
...
</form>
With the backend having the function :
protected void ValidateDiscount(object sender, EventArgs e)
{
this.txtDesc.Text = "fetch from database using: " + txtCode.Text;
}
My issue is that wheneve I click on the Validate button, the form is submitted and I end up on the Paypal website. I used Jquery at first with preventDefault(), but that actually prevents my server-side function from firing. I've also tried putting a standard <button> or <input type='button'> tag instead, but I couldn't get it to fire my server-side function.
Is there any way to have the Validate button not submit the form, or should I just remove the action from the form and manually submit the form when clicking on the submit button?
You have set your form action to post to PayPal.
This is the action:
action="https://www.sandbox.paypal.com/cgi-bin/webscr"
Here is where you have it in you form tag:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"
id="payPalForm" runat="server">
Remove this from your form tag and it should postback to your application.

asp.net can't take the text of input text

This is my aspx
<p>Date: <input type="text" id="datepicker" >
<asp:Button id="BookingForDate" runat="server" OnClick="BookingForDate_Click" Text="Search"/> </p>
<table id="DateBookingTable" runat="server" style="visibility:hidden">
<tr><th>ID</th><th>PlanTime</th></tr>
</table>
on my code in c# I can't see datepicker
why?
note please that i can take all the controllers from id except this one.
I already tried restart the visual studio
You have 2 options
add runat="server" to the input
<input type="text" id="datepicker" runat="server" />
or create an TextBox
<asp:TextBox runat="server" id="datepicker"></asp:TextBox>
You should add
runat="server"
to your input. No you are using an html control and not an asp.net server side control. Hence you can't access the value of the textbox the way you want.
So try the following and then you will be able to access the value of your textbox:
<asp:TextBox id="datepicker" runat="server"/>
Then in your code behind class you can access the value of this textbox
datepicker.Text
Another approach, as I pointed initially, it would be the following:
<input type="text" id="datepicker" runat="server">
You forgot to add the runat-attribute to your input-tag. Try this:
<input type="text" id="datepicker" runat="server">
With that change, you should be able to access the element from code behind
See MSDN
You have not given name to your control and also add runat="server"
<input type="text" id="datepicker" runat="server" name='datepicker' />

Clear <input> field from code behind

To pass values from javascript to the code behind after a postback I use this code:
string strRowNumberTblOne = Request.Form["iRowNumberTblOne"];
<input type="hidden" id="iRowNumberTblOne" name="iRowNumberTblOne" value="" />
Is there a way to clear the input field from the code behind?
The Request.Form is read only.
Add runat="server". Then set its Value property.
Try this Instead of you can use Hidden TextBox , like this
<asp:TextBox ID="TextBox2" style="display:none" runat="server"></asp:TextBox>
In JavaScript
varResult = document.getElementById('<%= TextBox2.ClientID%>');

Categories

Resources