Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

make an accept button like the outlook accept button

Status
Not open for further replies.
Jul 28, 2011
167
NG
Hi everyone,

I need all the help I can get.

I'm working on an overtime application form for staffs in my company. In other to accomplish this, the applicant for overtime fills a form and submits. A mail is fired to his supervisor indicating an application is made (the mail contains a link). He logs in to the site, clicks the link in his email which takes him to the page for the application and populates a control showing the application. He then clicks on the accept or reject radio button to accept or reject.

All works fine! However, when I took it to the management, they simply rejected it saying they prefer a single image/link in the email that is clicked (like the one you get when invited for a meeting in outlook). You just click accept right there in your email and the application for overtime gets approved. In the case of reject, it should pop up a box that allows him to give a reason for rejecting.

I'm using VB.net on VS2008.

Is there a way to implement this.

Help please!

____________________
Men put up a strong face just to cover their weaknesses...good!
But a smile makes them live longer....
Which would you choose?

Think about it.
 
Yes this can be done. If they accept, you have to have the link call a handler on your site. This is a .ashx file. A handler is just a page, all the same functionality, with no UI. So, if they click the link, the handler on your site is called, when the code behind is run. The only problem with this is that you will have to find a way to give the user some feed back that it was accepted.
If they want to reject and you need to have them input a reason, then you will have to go to a page on your site that gives them this ability.
 
@jbenson001: Thanks a whole bunch for your response.

So, you mean if I use a .ashx on my site, and the link is clicked, it wont pop up my web page (but rather perform the operation on the background)?

Ok, thanks, I'd give it a shot.
 
@jbenson001: I tried your concept and it seems to always take me to the web page.

This is the code I put in the
Code:
<%@ WebHandler Language="VB" Class="approveOvt" %>

Imports System
Imports System.Web

Public Class approveOvt : Implements IHttpHandler
    
    Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
        'context.Response.ContentType = "text/plain"
        'context.Response.Write("Hello World")
        Dim uid As String = context.Request.QueryString("uid")
    End Sub
 
    Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
        Get
            Return False
        End Get
    End Property

End Class
When I click on the approve link it keeps taking me to the web page.

Did I do anything wrong
 
At the code behind (in vb.net), I have this
Code:
Dim SmtpServer As New SmtpClient()
    Dim mail2boss As New MailMessage()
    Dim msg2Boss As String
    mail2boss.From = New MailAddress("noreply@us.com")
    mail2boss.Subject = "Approval required"

      msg2Boss = "<div style='font-family:'Trebuchet MS', Arial, Helvetica, sans-serif;'>Your staff " & hidStaffName.Value & " has just applied for overtime.<br /><br />"
      msg2Boss &= "Reason for overtime: " & txtOvtRsn.Text & "<br /><br /><br />"
      msg2Boss &= "Be informed that " & hidStaffName.Value & " has done " & calcTimeInt(hdfTotTimeInSecs.Value) & " of overtime this month<br /><br />"
      msg2Boss &= "<span style='font-size:10px;'>Note: You need to click the below buttons once (DO NOT DOUBLE-CLICK)</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
      msg2Boss &= "<a href='" & hostAddr & "/approveOvt.ashx?u=" & _1stLevelSup & "&lvl=1&uid=" & txtStaffId.Text & "&date=" & txtDayApplied.Text & "&up=1' style='padding:3px 10px; background:#0F0; border:2px outset; color:#FFF; text-decoration:none;'>&nbsp;&nbsp;&nbsp; Approve &nbsp;&nbsp;&nbsp;</a>"
      msg2Boss &= "&nbsp;&nbsp; OR &nbsp;&nbsp;"
      msg2Boss &= "<a href='" & hostAddr & "/approveOvt.ashx?u=" & _1stLevelSup & "&lvl=1&uid=" & txtStaffId.Text & "&date=" & txtDayApplied.Text & "&up=0' style='padding:3px 10px; background:#F36; border:2px outset; color:#FFF; text-decoration:none;'>&nbsp;&nbsp;&nbsp; Deny &nbsp;&nbsp;&nbsp;</a>"
      msg2Boss &= "<br /><br />If you cant click on the button above, copy below and paste in your browser address bar then hit enter.<br /><br />"
      msg2Boss &= "to approve -> " & hostAddr & "/approveOvt.ashx?u=" & _1stLevelSup & "&lvl=1&uid=" & txtStaffId.Text & "&date=" & txtDayApplied.Text & "&up=1 <br />OR<br />"
      msg2Boss &= "to deny -> " & hostAddr & "/approveOvt.ashx?u=" & _1stLevelSup & "&lvl=1&uid=" & txtStaffId.Text & "&date=" & txtDayApplied.Text & "&up=0"
      msg2Boss &= "<br /><br /><br /><br /><br /><br />"
      msg2Boss &= "<span style='font-size:10px;'>You cannot reply to this mail since it is an automatically generated mail.<br />Thank you</span>"
      msg2Boss &= "</div>"
 
    mail2boss.body = msg2Boss 
    mail2boss.IsBodyHtml = True    'Send mail as HTML format.
    SmtpServer.Send(mail2boss)

So this mail gets sent with the query string as shown in the mail. In the mail, the receiver gets two button-like prompts saying "Approve" Or "Deny" (I have not implemented the ashx, but simply put that bare-bone as shown above). I click on the approve button, but it keeps launching a page for me.

That's why I need your help.

Thanks in anticipation.
 
Please post the rendered HTML from the page that displays the links.
 
If I don't put a line like context.Response.Write("Hello World"), I get this error similar to below

Code:
XML Parsing Error: no element found
Location: [URL unfurl="true"]http://localhost:51014/intranet_9/HR/approveOvt.ashx?u=ahassan&dept=003&lvl=1&uid=LPS00628&date=11/14/2012&up=1[/URL]
Line Number 1, Column 1:
 
You are not understanding me
I need to see the rendered HTML, the page with the links on it. So, basically I need to see the "view source" of the page or email that is generated.(ie Right click the page and "view source")
I need to see what the user is seeing and more importantly, the HTML behind the message.
 
Oh! Ok, Sorry jbenson;

The message as it shows at the recipients email client (HTML) is this:
Code:
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<div style="font-family:" TrebuchetMS?,Arial,Helvetica,sans-serif;?="">
Your staff James Joe has just applied for overtime.<br><br>
Reason for overtime: Why do you ask<br><br><br>
Be informed that James Joe has done 5 Hours 0 Minutes 0 Seconds of overtime this month<br><br>
<span style="font-size:10px;">Note: You need to click the below buttons once (DO NOT DOUBLE-CLICK)</span><br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="[URL unfurl="true"]http://localhost:51014/intranet_9/HR/approveOvt.ashx?u=ahassan&amp;dept=003&amp;lvl=1&amp;uid=LPS00628&amp;date=11/15/2012&amp;up=1"[/URL] style="padding:3px 10px; background:#0F0; border:2px outset; color:#FFF; text-decoration:none;">&nbsp;&nbsp;&nbsp; Approve &nbsp;&nbsp;&nbsp;</a>&nbsp;&nbsp; OR &nbsp;&nbsp;<a href="[URL unfurl="true"]http://localhost:51014/intranet_9/HR/deny.aspx?u=ahassan&amp;dept=003&amp;lvl=1&amp;uid=LPS00628&amp;date=11/15/2012&amp;up=0"[/URL] style="padding:3px 10px; background:#F36; border:2px outset; color:#FFF; text-decoration:none;">&nbsp;&nbsp;&nbsp; Deny &nbsp;&nbsp;&nbsp;</a><br><br>
If you cant click on the button above, copy below and paste in your browser address bar then hit enter.<br><br>
to approve -&gt; [URL unfurl="true"]http://localhost:51014/intranet_9/HR/approveOvt.ashx?u=ahassan&amp;dept=003&amp;lvl=1&amp;uid=LPS00628&amp;date=11/15/2012&amp;up=1[/URL] <br>OR<br>
to deny -&gt; [URL unfurl="true"]http://localhost:51014/intranet_9/HR/deny.aspx?u=ahassan&amp;dept=003&amp;lvl=1&amp;uid=LPS00628&amp;date=11/15/2012&amp;up=0<br><br><br><br><br><br><span[/URL] style="font-size:10px;">You cannot reply to this mail since it is an automatically generated mail.<br>
Thank you</span></div>
 
Ok, so you are saying that if you click the approve link it is taking you to deny.aspx?
If so, I don't see how that is possible since the HTML looks correct. This will work if you click the link from YOUR development PC. If you are clicking it from
another PC, then you would get an error.. most likely a 404(page not found).
 
No, It takes me (correctly) to approve.ashx.

The thing is that I want all the code in the ashx file to run without showing as a web page. That is, you click on the accept button (no web page should pop up) but the code runs in the background (as it does when you click accept in a meeting invite in outlook)

Currently, when I click on the Accept button, it runs the code correctly, but still displays the approve.ashx as a web page (even though it gives that error above) i.e.
Code:
XML Parsing Error: no element found
Location: [URL unfurl="true"]http://localhost:51014/intranet_9/HR/approveOvt.ashx?u=ahassan&dept=003&lvl=1&uid=LPS00628&date=11/14/2012&up=1[/URL]
Line Number 1, Column 1:
 
The ashx is not showing as a page, you are seeing an error page if I am reading your post correctly. You need to debug to determine the error.
 
No, no, no! Please don't get me wrong, the code runs fine and executes properly. However, during and after execution (i.e as soon as I click the link), a page is shown (in the browser, you see the activity or progress indicator).
The thing is; I don't want to see a page showing when I click the link. I want all the code to execute underground and I do not know if this is possible

Also note: if I put the line...
Code:
context.Response.Write("Hello World")
in the ashx file, I don't get to see the error (and quite frankly, I do not think it is an error, but a browser response saying it could not find an element... html, head, body, etc.) but the Hello World shown on the page.

The point is; I don't even want to see a page launch while the code executes, but that the code should execute in the background when I click link!!!
 
If you are seeing a page, then you must have something else going on. Are you using any AJAX controls anywhere. I have used handlers extensively and never have seen a progress bar. So you will have to investigate what may be causing the issue. Remember, handlers have no UI so it is not the handler doing it. Even if you put in the Hello World line, it still will not show in a page, UNLESS you call the handler from a page and show that in a control. Just simply calling a handler will not show anything.
 
Ok Friend, Thanks for all the support so far. You have done a whole lot in pointing me in some direction.

Really appreciate it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top