Re: Mystery Variable Change
From: Hermit Dave (hermitd.REMOVE_at_CAPS.AND.DOTS.hotmail.com)
Date: 08/31/04
- Next message: Nicole Calinoiu: "Re: localhost SQL Server does not exist after XP SP2"
- Previous message: bruce barker: "Re: controls on a base page not available?"
- In reply to: Ron: "Re: Mystery Variable Change"
- Next in thread: Ron B: "Re: Mystery Variable Change"
- Reply: Ron B: "Re: Mystery Variable Change"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 31 Aug 2004 18:47:21 +0100
hello Ron,
we all use different forms of authentication. i have use forms
authentication in past and you create a ticket which is stored in the
authentication cookie.. i have used the ticket to store basic user info like
id, first name + last name + email address.
now if a user comes to the edit page and has already authetication then you
either have you ticket or values like session parameter etc.
now when it comes to the edit page. with user logged in.. what i am saying
is that why do you need to have a radio button to say whether user wants to
change the password or not. the update statement would be way simple in you
just update everything rather than the modified field. its just a question
of how many fields you are updating. as long as the number is small it
wouldnt make much of a performance difference
so what i am saying is that instead of giving the user an option to change
the password... just read it and update it (if the user has modified the
value the new passwords could be updated else the old ones will be over
written with the same again)
plus you could speed up the whole process by using sql query instead of
dynamically generating the query.
what it any clearer this time ?
-- Regards, Hermit Dave (http://hdave.blogspot.com) "Ron" <Ron@discussions.microsoft.com> wrote in message news:CD70F7DC-0C1B-4A5D-A4D4-BBC45BC7AB78@microsoft.com... > Thanks for the response Hermit. Unfortunately you are speaking a little above > my head. Can you try that again a little slower? Thanks again. > > "Hermit Dave" wrote: > > > why change the global variable to modify the query. Have a global user class > > which reflects user add / edit / get info all the crap > > > > when the page is posted first check whether the user is an existing user > > editing their profile (i use viewstate to store the id but for user i would > > have the id in the authentication ticket.) > > you could then check the radiobuttonlist to see what was selected. if fact i > > wouldnt even do that... i would just do an update with original password > > again what the heck. > > > > Plus instead of using direct sql queries you could just use stored > > procedures. > > > > -- > > > > Regards, > > > > Hermit Dave > > (http://hdave.blogspot.com) > > "Ron B" <Ron B@discussions.microsoft.com> wrote in message > > news:A3FAA5BB-5066-40D6-BAB5-B19E95419084@microsoft.com... > > > Hi, > > > I am gripping my mouse quite tightly b/c either I am blind or there is a > > > ghost in my cpu. > > > > > > Background: I am writing an Asp.net page that takes new user information > > > and > > > also doubles as a page for current users to edit their info. On the page > > > are > > > two PW boxes which a current user can disable or enable (using a > > > radiobuttonlist) depending on whether or not they want to change their > > > password while they are changing their other info. The radiobutton should > > > trigger the disabling/enabling of the two PW boxes as well as the > > > validation > > > on those boxes. It should also change a global boolean variable which will > > > determine how the Update statement will look (w/ or w/o the password > > > field.) > > > > > > Problem: Everything works fine except for the PassOn boolean variable > > > which > > > in turn effects whether the PW gets used in the Update command. I have > > > placed response.writes all over the place to determine why it doesn't work > > > to > > > no avail. It seems that somehow the variable, PassOn, gets changed to > > > false > > > all by itself when the page is loaded. I don't get it. Please help. > > > > > > Code: > > > <script runat="server"> > > > dim FormTypeVar as string = "New" > > > dim strconnection as string = "myconnection" > > > dim objconnection as New SqlConnection(strConnection) > > > dim PassOn as boolean > > > > > > sub page_load (source as object, e as eventargs) > > > > > > FormType.text = "Enter New Employee" > > > > > > if len(session("empnum")) = 6 then > > > FormTypeVar = "Edit" > > > FormType.text = "Edit Personal Information" > > > else > > > emppass.enabled = true 'PW txtbox > > > empconfirm.enabled = true 'Confirm PW txtbx > > > pwvalid.enabled = true 'PW txtbx validation > > > end if > > > If (not ispostback) and (formtypevar = "Edit") then > > > > > > 'only place this var is changed in the page_load proc. should not be > > > triggered > > > '(and is not based on response.write) when radiobutton is changed > > > PassOn = false > > > > > > passchange.enabled = true 'radiobutton list > > > fill_page() 'fills page w/ user info > > > passchange.items(1).Selected=true > > > 'auto selects No > > > end if > > > > > > end sub > > > > > > sub submit_click (sender as object, e as eventargs) > > > If page.isvalid then > > > If FormTypeVar = "New" Then > > > > > > 'Enter new employee code > > > > > > Else > > > > > > dim PassString as string > > > if PassOn = true then > > > PassString = "emp_pass = '" & emppass.text & "', " > > > else > > > PassString = "" > > > end if > > > dim strSQL as String = "UPDATE employees " & _ > > > "SET emp_num = '" & empnum.text & "', " & _ > > > "emp_first = '" & empfirst.text & "', " & _ > > > "emp_last = '" & emplast.text & "', " & _ > > > "emp_title = '" & emptitle.text & "', " & _ > > > "emp_dept = '" & empdept.text & "', " & _ > > > "emp_site = '" & empsite.selecteditem.value & "', " & _ > > > "emp_add = '" & empadd.text & "', " & _ > > > "emp_work = '" & empwork.text & "', " & _ > > > "emp_fax = '" & empfax.text & "', " & _ > > > "emp_home = '" & emphome.text & "', " & _ > > > "emp_email = '" & empemail.text & "', " & _ > > > "emp_mgr = '" & empmgr.text & "', " & _ > > > "emp_mgr_phone = '" & empmgrnum.text & "', " & _ > > > PassString > > > " WHERE emp_id = " & session("empid") > > > > > > Connect() > > > dim dbComm as New SqlCommand(strSQL, objConnection) > > > dbcomm.executenonquery() > > > Disconnect() > > > response.Redirect("mainmenu.aspx") > > > > > > End if > > > End if > > > end sub > > > > > > sub togglepass(sender as object, e as eventargs) > > > dim temp as boolean = passchange.selecteditem.value > > > if temp then > > > PassOn = true > > > emppass.enabled = true > > > empconfirm.enabled = true > > > pwvalid.enabled = true > > > else > > > PassOn = false > > > emppass.enabled = false > > > empconfirm.enabled = false > > > pwvalid.enabled = false > > > end if > > > end sub > > > > > > sub password_validate(sender as object, args as servervalidateeventargs) > > > if PassOn = false then > > > args.isvalid=true > > > exit sub > > > end if > > > dim temp1, temp2 as string > > > temp1 = emppass.text > > > temp2 = empconfirm.text > > > if temp1 = "" or temp2 = "" then > > > args.isvalid = false > > > pwvalid.errormessage = "You must enter your new password twice." > > > exit sub > > > end if > > > if temp1 <> temp2 then > > > args.isvalid = false > > > else > > > args.isvalid = true > > > end if > > > end sub > > > </script> > > > <body> > > > > > > <!--Other asp.net controls, i.e. last name, first name etc.--> > > > > > > <asp:TextBox id="emppass" runat="server" textmode="password" Columns="25" > > > enabled="false"/> > > > <asp:CustomValidator > > > id="pwvalid" > > > OnServerValidate="password_validate" > > > errormessage="Your passwords did not match, please try again." > > > runat="server" Enabled="false">*</asp:customValidator> > > > > > > <asp:TextBox id="empconfirm" runat="server" textmode="password" > > > Columns="25" > > > enabled="false"/> > > > > > > Change your password? > > > <asp:RadioButtonList ID="passchange" Enabled="false" RepeatColumns="2" > > > OnSelectedIndexChanged="togglepass" > > > AutoPostBack="true" runat="server" > > > > <asp:ListItem Value=true Text="Yes" /> > > > <asp:ListItem Value=false Text="No" /> > > > </asp:RadioButtonList> > > > </body> > > > > > >
- Next message: Nicole Calinoiu: "Re: localhost SQL Server does not exist after XP SP2"
- Previous message: bruce barker: "Re: controls on a base page not available?"
- In reply to: Ron: "Re: Mystery Variable Change"
- Next in thread: Ron B: "Re: Mystery Variable Change"
- Reply: Ron B: "Re: Mystery Variable Change"
- Messages sorted by: [ date ] [ thread ]