Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 13th, 2004, 03:08 AM
Registered User
 
Join Date: Dec 2004
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


 
Old December 13th, 2004, 03:27 AM
Friend of Wrox
 
Join Date: Jun 2004
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
 
Old December 13th, 2004, 05:28 AM
Authorized User
 
Join Date: Aug 2003
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:)

 
Old December 13th, 2004, 05:32 AM
Authorized User
 
Join Date: Aug 2003
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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







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





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