[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Summary to Detail Page using a Button

Posted on 2014-01-06
3
Medium Priority
?
404 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 70

Assisted Solution

by:Jason C. Levine
Jason C. Levine earned 525 total points
ID: 39760377
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 525 total points
ID: 39760435
<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 54

Expert Comment

by:Scott Fell, EE MVE
ID: 39760456
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

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
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…
Suggested Courses

650 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