This topic is locked

Link to Edit page from Menu

4/25/2007 11:41:13 PM
ASPRunnerPro General questions
Q
qqqqq author

Hi,
Can I put a link to edit a record directly on the menu? If the security is set up to only allow them to see and edit their own data and the table only has one value, like their user account, then it would look better to just skip the table view and have a link directly to the editing. How can I do this?
Thanks.

Q
qqqqq author 4/25/2007

I guess I should add this info, the table has an autonumber as its primary key. The edit page uses this field and the user name as parameters. I can get the username into a link but can't see how to get the other field.

J
Jane 4/26/2007

Hi,
you can do it using AfterSuccessfulLogin event on the Events tab.

Here is a sample code:

Sub AfterSuccessfulLogin()

str = "select FieldID from TableName where UserName='" & Session("UserID") & "'"

Set rsTemp = server.CreateObject("ADODB.Recordset")

rsTemp.open str, dbConnection

if not rsTemp.eof then

Response.Redirect "users_edit.asp?editid1=" & rsTemp("FieldID") & "&editid2=" & Session("UserID")

else

Response.Redirect "menu.asp"

end if

End Sub



where FieldID and UserName are your actual field names, RableName is your actual table name.

Q
qqqqq author 4/26/2007

Hi,

you can do it using AfterSuccessfulLogin event on the Events tab.

Here is a sample code:
where FieldID and UserName are your actual field names, RableName is your actual table name.


Hi Jane,
Thanks for your response. I don't think that's quite what I'm looking for though. It looks like your code is sending them to the edit page automatically after they logon? I'd like to have a link on the menu page that goes to the edit page. Is there a way to do this?

J
Jane 4/27/2007

Hi,
try to use ListOnLoad event to redirect to the edit page.

Here is a sample:

Sub ListOnLoad()

str = "select FieldID from TableName where UserName='" & Session("UserID") & "'"

Set rsTemp = server.CreateObject("ADODB.Recordset")

rsTemp.open str, dbConnection

if not rsTemp.eof then

%><script>

window.location='./users_edit.asp?editid1=<%=rsTemp("FieldID")%>&editid2=<%=Session("UserID")%>';

</script><%

else

%><script>

window.location='./menu.asp';

</script><%

end if

End Sub