Stop asking for save password [duplicate] - c#

This question already has answers here:
Disable browser 'Save Password' functionality
(35 answers)
Closed 7 years ago.
I'm using ASP.NET 2008 to create an web application with login page "Login.aspx". In that I've use control. Inside that I've created a table structure to place the controls and in that I've place username and password textboxes.
<asp:Login ID="LoginUser" LoginButtonStyle-CssClass="CommonButton" runat="server"
OnLoggedIn="LoginUser_LoggedIn" OnLoginError="LoginUser_Error" TitleText=""
Width="100%" DisplayRememberMe="true" OnLoggingIn="LoginUser_LoggingIn">
<div style="margin-left: auto; margin-right: auto;">
<table border="0" cellpadding="0" style="margin-left: auto; margin-right: auto;">
<tr>
<td style="padding-bottom: 8px;">
<asp:TextBox ID="UserName" runat="server" autocomplete="off" CssClass="CommonTextBox" Width="325" TextMode="SingleLine"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:TextBox ID="Password" runat="server" autocomplete="off" CssClass="CommonTextBox" Width="325" TextMode="Password"></asp:TextBox>
</td>
</tr>
</table>
</div>
</asp:Login>
Now when I enter username and password, the browser prompts for save password. But I don't need that prompt.
I'm not using any HTML controls. Its all ASP.NET controls.
How to prevent browser from prompt..?
I've used everything that was already answered. But nothing worked for me. That's why Ive asked newly. I searched for many possible ways, and all failed. This is not a duplicate one.

In your form in the HTML set the attribute autocomplete="off"
<form autocomplete="off" id="form1">

Related

Read text from textarea/textbox in HTML into C# codebehind. (ASP.NET)

I'm trying to use code behind to read text from HTML provided to me. After researching this topic I found that almost all instances of this involve Web Forms controls(asp:) for the textboxes but the HTML I was given does not, but instead is:
<p>
<label>Address</label>
<textarea class="w3-input w3-border" name="addr" cols="30" rows="4"></textarea>
</p>
<div class="w3-half w3-container">
<p>
<label>Phone:</label>
<input type="text" class="w3-input"/>
</div>
<div class="w3-half w3-container">
<label style="padding-left:10px;">Email:</label>
<input type="text" class="w3-input"/>
</div>
</p>
Will I still be able to read the user-provided text from these boxes or will I need to alter the HTML?
A couple of my unsuccessful code-behind attempts to extract the address supplied:
string address = ((textarea)Address.FindControl("addr")).Text;
string address = ((TextBox)Address.FindControl("addr")).Text;
Update:
Using the server control described in a solution offered, I get an error message stating that "A page can have only one server-side Form tag."
This results from the following markup:
<form runat="server">
<asp:textbox id="addr" runat="server" textmode="multiline" />
</form>
followed later by:
<form runat="server">
<asp:Button ID="Ship" runat="server" Text="Ship" OnClick="Ship_Click" style="padding: 10px; margin-bottom: 10px;" class="w3-round w3-blue" />
<asp:Button ID="Rate" runat="server" Text="Rate" OnClick="Rate_Click" style="padding: 10px; margin-bottom: 10px;" class="w3-round w3-blue" />
</form>
The textarea is located in a different section than the buttons and I'm unclear on how to make both functional either without a form tag or without having them share the same one. Thanks
You need to use a server control if you're looking to access the value in code behind. Use an ASP TextBox and set the TextMode to MultiLine:
<asp:TextBox ID="textarea1" runat="server" TextMode="MultiLine" />
Then in code behind:
string addr = textarea1.Text;
UPDATE to demonstrate multiple forms on the same page:
<form ID="form1" runat="server">
<asp:Button ID="Ship" runat="server" Text="Ship" OnClick="Ship_Click" style="padding: 10px; margin-bottom: 10px;" class="w3-round w3-blue" />
<asp:Button ID="Rate" runat="server" Text="Rate" OnClick="Rate_Click" style="padding: 10px; margin-bottom: 10px;" class="w3-round w3-blue" />
</form>
<form id="form2" action="WebForm1.aspx" method="post">
<asp:TextBox ID="textarea1" runat="server" TextMode="MultiLine" />
</form>
From here, you can use either method of retrieving the textarea1 value in code behind for posts from form1 or form2...
form1:
string addr = textarea1.Text;
form2:
string addr = Request["textarea1"].ToString();
Add runat="server" to your TEXTAREA and INPUT tags. Then you can access them from code-behind. You also need to assign the ID attribute of each one.
<p>
<label>Address</label>
<textarea class="w3-input w3-border" name="addr" id="textarea1" runat="server" cols="30" rows="4"></textarea>
</p>
<div class="w3-half w3-container">
<p>
<label>Phone:</label>
<input type="text" class="w3-input" runat="server" id="input1" />
</div>
<div class="w3-half w3-container">
<label style="padding-left:10px;">Email:</label>
<input type="text" class="w3-input" runat="server" id="input2" />
</div>
</p>

html input of type File wrapped inside ASP: Panel is not disabled when panel is disabled

I have wrapped HTML Input control of type File inside ASP:Panel control(which is wrapped inside update panel).
When I disable ASP:Panel control, input control is still enable. Please helpme out
ASPX Code :
<asp:Panel ID="pnlBrowseCSV" runat="server" Enabled="true">
<table>
<tr>
<td align="left" valign="top" style="height: 30px; width: 160px;">
<strong>CSV File:</strong>
</td>
<td style="height: 30px">
<input type="file" id="csvFile" runat="server"
onkeydown="return false" style="width: 350px; background-color:white"/>
<strong>(*.csv)</strong>
</td>
<td style="height: 30px">
<ASP:Button ID="btnValidate" Text="Validate" runat="server"
OnClick="btnValidate_Click" />
</td>
</tr>
</table>
</asp:Panel>
Using visible attribute instead of Enabled.
<asp:Panel ID="pnlBrowseCSV" runat="server" Visible="False">
This issue is by design. What you can do rather is write one extra line of code to disable File upload where you disable the panel.
pnlBrowseCSV.Enabled = false;
csvFile.Enabled=false;

How to access to code viewable only in browser's "View source"?

Ok, this is weird. I am working on a GIS web site, and i have the next problem. I need to tweak one of the main functions in the site (because i constantly get an error about one of its lines); the problem is that i can't see that chunk of code in any way! I know where it is, because when i open the page with "View Source" browser's option (Chrome), i see the code i need to change, but that is the only way i can see it! I tried Dreamweaver, Notepad++, Visual Studio 2008 (because it's an .aspx page), still nothing. Here is the preview:
<body>
<form id="form1" runat="server">
<div align="center">
<asp:PlaceHolder ID="phScript" runat="server"></asp:PlaceHolder>
<hr />
<br />
<table style="width: 50%;">
<tr>
<td style="font-family: 'Times New Roman', Times, serif; font-size: large;font-weight: bold;">
<asp:Label ID="lblTitol" runat="server" Text="CÀLCUL ÀREES D'INFLUENCIA AL VOLTAN D'UNA ENTITAT"></asp:Label>
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
And this is that portion of code as seen in browser's source:
<body>
<form name="form1" method="post" action="zi.aspx" id="form1">
<div align="center">
<SCRIPT language="javascript" type="text/javascript">parent.frames['map'].Oper='4';parent.frames['map'].MetodeTreball='ILLES';parent.frames['map'].Iter='1';parent.frames['map'].Entitats='CEIP';parent.frames['map'].RadiFix='400';parent.frames['map'].Cobertura='100';parent.frames['map'].ReloadMap(1200);</SCRIPT>
<br />
<br />
<br />
<hr />
<br />
<table style="width: 50%;">
<tr>
<td style="font-family: 'Times New Roman', Times, serif; font-size: large; font-weight: bold;">
<span id="lblTitol">CÀLCUL ÀREES D'INFLUENCIA AL VOLTAN D'UNA ENTITAT</span>
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
It is the JavaScript part with parent.frames bla bla part that i have to change, if i can. As i can see, that portion of the code is in aspPlaceHolder, is there any way i can access that part and change it? Sorry for this much code, but i tried to explain the problem as closely as i can.
Remember, the source code you are seeing in the first part is the source code of the ASPX file. This will be parsed by the ASP.Net runtime and the HTML sent to the client. So what you want to do is look at the code that is updating the asp:PlaceHolder called phScript.
If you have access to the source code, this will be in the code behind for the ASPX page - it will have the same name but the extension .cs.
This should tell you where and how the javascript is being constructed, at least.
Search for something like phScript.Controls / phScript.Controls.Add in the code-behind file of that aspx file.
Search the project for the term phScript to see what's populating the phScript PlaceHolder.
In visual stdio 2010 when ever a page is rendered to client it is also shown in Solution explorer at the top. This is same code which is viewable in View source of browser.

Required Validator and compare validators do not work!

I am trying to see the validation part working. I have few required field validators and compare field validators, etc.
<div>
<asp:RequiredFieldValidator ID="rfvCompany" ValidationGroup="groupProfile"
ControlToValidate="txtCompany" runat="server"
ErrorMessage="- Company Name Required" Display="Dynamic" />
</div>
<div>
<asp:RequiredFieldValidator ID="rfvAddress" ValidationGroup="groupProfile"
ControlToValidate="txtAddress" runat="server"
ErrorMessage="- Address 1 Required" Display="Dynamic" />
</div>
This is my save button, validation has to happen when this button is clicked.
<tr>
<td align="center">
<asp:ImageButton ID="btnSave" runat="server" ImageUrl="~/images/green-save.gif"
OnClick="btnSave_Click" TabIndex="22" ValidationGroup="groupProfile" />
</td>
</tr>
The popup that comes when the save button is clicked is this..
<tr>
<td colspan="2" align="left" style="padding-left: 75px; padding-top: 10px;">
Do you wish to update the Location Information as well.
</td>
</tr>
<tr>
<td align="center" colspan="4">
<asp:Button ID="btnYesMerchant" Text ="Yes" runat="server" class="popupButton"
causesvalidation="true" OnClientClick="$find('mdlpop').hide(); return true;"
onclick="btnYessave_Click"/>
<asp:Button ID = "btnNoMerchant" Text ="No" runat ="server" class="popupButton"
causesvalidation="true" OnClientClick="$find('mdlpop').hide(); return true;"
onclick="btnNosave_Click"/>
<asp:Button Id="btnCancel" Text ="Cancel" runat="server" class="popupButton" />
</td>
</tr>
Where am i doing wrong? i am in a serious mess, i guess :(
Ensure you have included the asp:ScriptManager on your page. In addition to that check for javascript errors and (if any) add them to your question.
Here i have assigned the popup to the button, so the popup is being called when the button is clicked. Now i have changed the flow. For the button, i have written a javascript function that will validate and calls the popup to show if validation is passed. This worked. Thank you all..

Yes No Cancel (3 buttons) for AJAX Modalpopupextender

Does Ajax ModalPopupExtender has an option to create 3 buttons? Yes, No and Cancel? for ASP.NET WebForms, C#
I could not come up with a solution. I can just find OKControlID and CancelControlID.
<table id="pnlPopupMerchantUpdate" runat="server" style="display:none">
<tr>
<td>
<asp:Panel runat="server" CssClass="modalPopup">
<table width="350" height="80" class="warningPopup">
<tr>
<td>
<!-- <img src="images/warning_blue.gif" alt="Warning" /> -->
</td>
<td colspan="2" align="left" style="padding-left: 75px; padding-top: 10px;">
Do you wish to update the Location Information as well.
</td>
</tr>
<tr>
<td align="center" colspan="4">
<input id="btnYesMerchant" type="button" value="Yes" class="popupButton" causesvalidation="true" onclick="btnYessave_Click"/>
<input id="btnNoMerchant" type="button" value="No" class="popupButton" causesvalidation="true" onclick="btnNosave_Click" />
<input id="btnCancel" type="button" value="Cancel" class="popupButton"/>
</tr>
</table>
</asp:Panel>
</td>
</tr>
Here, I do want to call different functions for Yes and No.
Instead of OKontrolID, you can use extender's client side API to hide it on button's on-click event. See this article that shows multiple cancel button - your scenario is similar, you just need to return true from your button's onclick event handler.
<ajaxToolkit:ModalPopupExtender runat="server" BehaviorID="myPopup" ...
and
<input id="btnYesMerchant" type="button" onclick="$find('myPopup').hide(); return true;" ...
Thought i found it to be so tough, it is simple to handle this problem. We just got to add return true for each asp button.
ANd remove the OKCOntrolID from ModalPopupExtender. It solved my problem. Thanks all who gave it a try reading.

Categories

Resources