Solved

Summary to Detail Page using a Button

Posted on 2014-01-06
3
383 Views
Last Modified: 2014-01-09
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.
0
Comment
Question by:slegy
3 Comments
 
LVL 70

Assisted Solution

by:Jason C. Levine
Jason C. Levine earned 175 total points
Comment Utility
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
 
LVL 82

Accepted Solution

by:
leakim971 earned 175 total points
Comment Utility
<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
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
This article is very specific and is only intended to help if you are installing Dreamweaver 8 in a Windows 7 environment with Office 2007 installed.   I'm not sure why Microsoft tends to release OS' that should not be released but they do.  Windows…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now