Summary to Detail Page using a Button

I have a summary page which lists events, each with a unique ID. Currently, the user can click on "Edit" and be taken to the detail page to edit the event. What I would like to do is replace "Edit" with a button that goes to a routine which checks to see if the user is logged in before going to the detail page. I'm using Dreamweaver CS4. Is that possible?

Here is the code for the current "Edit" button:

<td width="20" class="hpResults"><div align="center"><a href="eventupdate.asp?ID=<%=(rseventCalendar.Fields.Item("ID").Value)%>"><span class="eventeditLink">Edit</span></a></div></td>

Open in new window


I tried saving the ID but was not successful.
slegyAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jason C. LevineDon't talk to me.Commented:
Easiest way would be to send all Edit clicks to a new page with a query string of the eventID:

<a href="loggedIn.asp?ID=<%=(rseventCalendar.Fields.Item("ID").Value)%>"><span class="eventeditLink">Edit</span></a>

On the loggedIn.asp page, perform the test to see if the user is logged in (check for cookie, session, whatever you are using to validate) and redirect them to either the edit page or the login page appropriately.
0
leakim971PluritechnicianCommented:
<td width="20" class="hpResults">
      <div align="center">
              <a href="eventupdate.asp?ID=<%=(rseventCalendar.Fields.Item("ID").Value)%>">
                        <span class="eventeditLink">Edit</span>
              </a>
       </div>
</td>

add this in the head section of your page :
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
   jQuery(function($) {
         $("a[href^=eventupdate.asp]").click(function(event) {
              var isLoggedIn = null;
              $.ajax({ url:"checkIfLoggedIn.asp", success: function(status) { isLoggedIn = (status=="OK"); }, async:false });
              if( !isLoggedIn ) {
                  event.preventDefault(); // stop!!!!
                  alert("YOU'RE NOT LOGGED IN");
                  // location.href = "/login.asp"; // uncomment to redirect to loggin page
              }
         });
   });
</script>

Open in new window


I used jQuery to simplify the code. We can of course use simple Javascript, it's essentialy a synchronous ajax call.

Your script checkIfLoggedIn.asp should return (and only return) OK if the user is logged.
A simple one :
<%
Response.Write ("OK")
%>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Are you using dreamweaver's code to log in?  If you are, then you can use the Server Behavior > User Authentication > Restrict Access to Page.  

You will end up with some type of code that looks like
<%
' *** Restrict Access To Page: Grant or deny access to this page
MM_authorizedUsers=""
MM_authFailedURL="good_by_not_logged_in.asp"
MM_grantAccess=false
If Session("MM_Username") <> "" Then
  If (true Or CStr(Session("MM_UserAuthorization"))="") Or _
         (InStr(1,MM_authorizedUsers,Session("MM_UserAuthorization"))>=1) Then
    MM_grantAccess = true
  End If
End If
If Not MM_grantAccess Then
  MM_qsChar = "?"
  If (InStr(1,MM_authFailedURL,"?") >= 1) Then MM_qsChar = "&"
  MM_referrer = Request.ServerVariables("URL")
  if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" & Request.QueryString()
  MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" & Server.URLEncode(MM_referrer)
  Response.Redirect(MM_authFailedURL)
End If
%>

Open in new window

Make sure that is on the very top of your detail page.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Dreamweaver

From novice to tech pro — start learning today.