Load data from cookie event - asp.net

Please give peace of advice. I have login form. Login and password textboxes, and button 'enter'. Button disabled if textboxes are empty. So I've made client side event that makes button enable. Event TextChaged for both textboxes. But after entering to application users login and password wrote to cookies. When I entering the next time, I past the login name into the first box, password appears automatically. And 'enter' button still disabled. Does exist some event that occurs after cookies was paste?
ps: used devexpress textboxes

When you enter Login details second time, your textchange event should ideally have fired! and 'Enter' button should have been enabled. Are you sure its all working fine?
Alternatively, here is what you can do:
onblur event of the textbox, check the length of both the text boxes (Login & Password). If length is greater than zero for both textboxes, enable the Enter Button.
Hope it helps.

Related

asp disable button for the whole session

I would like to disable a submit button on a webform like proposed in:
How to disable postback on an asp Button
But the button should stay disabled, even when the user navigates to some other webpage in the application (like admin page) and then navigates back to the original page; (in my case the button is then not disabled anymore). So is there a way that this button stays disabled (for instance until the user logs off from the application) even in such events and for the whole session until the user logs off?
Thank you for your time and effort.
Add a session variable, example Session("btnDisabled") in the event where you want this to happen and check against it every time a page with the button loads.
If session("btnDisabled")=true then btnSomething.enabled=false
then when the user is logged out, you change that variable, either kill it or set it to false.

ASP.NET Multiple links validate

I have about 50 or so links similar to the following:
<asp:TableCell Font-Bold="true"><asp:Hyperlink ID="Hyperlink9" runat="server" CssClass="Hyptext" Name="HypLink1" TextDecorations="None" NavigateUrl="~/Folde1/Second.aspx" Text="Case Study 12 "/></asp:TableCell>
What I like to do is when the user clicks on the hyperlink, I like to validate that the user has permission to view the links. If so, they can view it. If not, a pop-up will come information them that they need to sign in order to view the links.
Questions
1) What is the best way when the user clicks on the HyperLink to do a server side click event. From what I seen,only a client side even can be done with the asp:Hyperlink. I like to then validate if they have permissions. If not, throw a pop-up window.
You should not do that. Instead, you should...
On server side, check to see if user is logged in...
if not logged in, provide login link and text "Login to see case studies".
if already logged in, provide links user has access to.
You need an onClick tag that points to a method. Create one event handler function and point all your hyperlinks to it. Once the event handler fires, cast the sender to Hyperlink and go from there.

stop password textbox to be empty when click on button?

i have a user name, password and a calendar button which when click, a calendar appear and insert the date selected into the date textbox field, and a submit button.
After, i key in value for user name and password and click on the calendar button, the password textbox field because empty. So how can i going to stop the password textbox field to become empty when i click i the calendar button??
i set visible calendar only when click on the button
<asp:Calendar ID="Calendar1" runat="server" Visible="False"></asp:Calendar>
is there a way?
For security reasons, ASP.Net clears a password textbox before sending it to the client. This happens for instance on a postback, after the click on that calendar has been processed.
Sounds like you are clearing it on postback in the codebehind. What does your PageLoad code look like?

ASP.NET 4 Password Recovery Validation failing in IE only

I'm using the ASP.NET Membership provider and using the Password Recovery control to reset the user password if they forget it. On the whole it all works fine, but with one catch when it comes to validation.
I have expanded the PasswordRecovery control out to use the template feature to customise the appearance, which is all fine. I have set the user lookup error handler using:
OnUserLookupError="PasswordRecovery1_UserLookupError"
in the opening tag and if I load up the page, type in some junk name and click submit this fires as expected, in all browsers. The snippet of VB code makes an error div visible and sets some text.
However, if upon loading the page for the first time I type a duff name into the username box and hit the enter key to submit the form, in Internet Explorer (version 8), the UserLookupError event fails to trigger. It triggers just fine in Chrome or Firefox, just not in IE. I know it's not a focus issue on the form, as I can see the form is being submitted.
If I click the submit button first, then following that hit the enter key it does fire, it's just that first time it doesn't, and only in IE.
Also to add that if I set breakpoints in the VB code to check to see if the page is being submitted, I can see the Page_Load event fire when I hit the enter key, but not the sub PasswordRecovery1_UserLookupError.
Has anyone else seen this? It looks like a bug in IE (no really???), but I need to nail it down.
Any help would be welcome.
OK, after some more digging and testing this is actually only a default button issue. I'm not sure what's happening when the enter key is being pressed (only in IE) after text has been entered in the box, as it is reloading the page but not submitting it. There is no other control or function on the page which would navigate back to or refresh this page.
Despite the submit button appearing to be the default button it actually isn't. The key here therefore is setting the defaultbutton property of the webform. That however, when the button is inside a PasswordRecovery control is another issue.
EDIT:
Here's the fix. Set the default button at the page load stage.
Me.Form.DefaultButton = PasswordRecovery1.UserNameTemplateContainer.FindControl("SubmitButton").UniqueID

ASP.NET validation

I have a little problem with the validation in one form
the form is composed by two taqs. There is a "Save" button in each tap (is the same control for both) and saves the form info. there are validation controls in one tab but not in the second. When we try to save the info from the second tab, and the info has not been filled in the first tab, the validators fire, and nothing happends, but because this validators are shown in the other tab, the end user might be thinking that the operation has been completed, instead, I would like to show a msgBox telling the user about the errors in the other tab. How do I know that the validators in the other tab have been fired, and display the error message when the button is clicked?
You should use the ValidationGroup of your validator controls and the appropriate submit button. You can also use a ValidationSummary control which displays a summary of the validation messages - this can be set to display a message box if you want by setting the property ShowMessageBox=true.
taqs - tap
dear why are you so confused?
All the validators are posted to the page as JavaScript functions. You can call the validation function on button's click and take the appropriate action.
You can use on buttons
onClientClick="Page_ClientValidate();"

Resources