Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 13th, 2004, 03:08 AM
Registered User
 
Join Date: Dec 2004
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default handling server side button visibility property

Hello evry body!!
can u pls help me out with this issue...
I designed a page havin 2 text boxes (user name,password)
and 2 server side buttons (asp:button) submit n reset password..
am codin in asp.net..
so now what i want is once the user gives his user name n password...
on password textbox blur event...the given credentials must be checked and based on the result the reset button must be visible or invisible... that is is the user is an authorised person only then he can reset the password else he can only submit the passwrod...
pls help me out in this issue!!
thank u


Reply With Quote
  #2 (permalink)  
Old December 13th, 2004, 03:27 AM
Friend of Wrox
 
Join Date: Jun 2004
Location: Chennai, Tamil Nadu, India.
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76
Default

Hi Shilpa,

You can try it out this method.

You can set the "AutoPostBack" property of the password textbox to "true" and write code in the "TextChanged" Event

private void txtPassword_TextChanged(object sender, System.EventArgs e)
{
        if (!ValidateUser())
         txtReset.Enabled = false;
}

However, I would advice not to use this method, since it would create unnecessary postbacks to the server. This is not an advisible methods in web applications.

Regards
Ganesh
Reply With Quote
  #3 (permalink)  
Old December 13th, 2004, 05:28 AM
Authorized User
Points: 325, Level: 6
Points: 325, Level: 6 Points: 325, Level: 6 Points: 325, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Altamonte Springs, FL
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi:
This doesn't look like it should be too hard.

You can do it a couple of different ways.

1. On the server side, when the user submits the form, in your button's onclick event or the proc that handles the edit, check to see if they have 'change my password' access and then either allow the change to take place or if they don't, just don't edit the password. That is, let them go ahead and change it, then handle it as you see fit after the fact, on the Server side.

If you've gotta have client side access to it you can do that:
In your Server Side Page_Load event (um, I'm using C#) enter this:

txtPassword.Attributes["onchange"]="javascript:checkPassword();";

In the client you'd need Javascript code like this:
<SCRIPT language="javascript">
<!--

function checkPassword()
{
  if("<%=(sPasswordIsEditable)%>" != "YES")
  {
      alert("You cannot change your password");
      theFORM.txtPassword.value = "<%=(sOldPassword)%>)";
  }
}
//-->
</SCRIPT>

I'm using 2 protected string variables that I'd have to set on the server side in the Page_Load proc:
sPasswordIsEditable - I used a string not a bool so the Client can see it easy; set to "YES" if user can set it.

sOldPassword - set to the user's password before he changes it.

Hope that helps:)

Reply With Quote
  #4 (permalink)  
Old December 13th, 2004, 05:32 AM
Authorized User
Points: 325, Level: 6
Points: 325, Level: 6 Points: 325, Level: 6 Points: 325, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Altamonte Springs, FL
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

uh, that one line should have been:
document.theFORM.txtPassword.value = "<%=(sOldPassword)%>)";


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem Converting Client-side to Server-side Code kwilliams ASP.NET 2.0 Professional 1 November 21st, 2007 05:25 PM
Server side on code on control property jayaraj123 ASP.NET 2.0 Professional 1 May 23rd, 2007 08:30 AM
Firing server side events at client side codes mehdi62b ASP.NET 1.0 and 1.1 Basics 6 May 18th, 2005 09:11 AM
handling server side buttons visibility property d shilpa528 Java GUI 0 December 13th, 2004 03:02 AM
Accessing Server Side Data on Client Side steve456 Classic ASP Professional 3 October 15th, 2003 02:33 PM



All times are GMT -4. The time now is 08:37 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.