Solved

ISAPI (button on HTML Page)

Posted on 2000-03-27
11
194 Views
Last Modified: 2010-08-05
I'm creating an ISAPI application

how can I receive the fact that a user has clicked(submit) on a butoon in a HTML PAGE ?

I've to use the TWebActionItem ?

Where I've to put my code to execute the function related to this button ?

Thanks a lot

Olivier
0
Comment
Question by:olisaac
[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
  • 4
  • 3
  • 2
  • +2
11 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 2660259
The following html-code could be a part on a page:

<FORM method=post action="cgi-bin/button.dll/click">
<input type=submit value=Search>
......


When the button is pressed, the ISAPI gets an action '/click'

In you ISAPI app double-click on the WebModule window. In the appearing window add a new actionitem. Set its PathInfo property to '/click'. Now write the OnAction event.

Eps.
0
 

Expert Comment

by:Dantry
ID: 2660419
Listening...
0
 
LVL 17

Expert Comment

by:geobul
ID: 2660420
Hi Olivier,

1. Receiving the fact of button click:
I've always named my buttons in HTML code like:
<INPUT TYPE=submit NAME="LoginBtn" VALUE="Login">

The Delphi code is:
....
if (Request.ContentFields.Values['LoginBtn'] <> '') then begin
  .....
end;
....
which means that exactly login button has been clicked. (if I have more btns on the page)

2. Using WebActionItems:
  It's recommended to have at least one Action Item with no PathInfo property (empty) and Default = True. That way all requests will be handled here.
  You can use BeforeDispatch event of the WebDispatcher also.
  For more complicated jobs you can use PathInfo after the name of your dll in different html pages to react with different Action Items depending on the PathInfo of the request. {see Epsylon's comment}

3. Where to put code:
  It depends on the answer of the question 2. If you are using different Action Items the code can be in the code of the proper item, in the default item, ih the before or after dispatch events.

Regards, Geo
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:Radler
ID: 2661196
0
 
LVL 4

Expert Comment

by:Radler
ID: 2661217
0
 
LVL 1

Author Comment

by:olisaac
ID: 2663195
Adjusted points from 50 to 75
0
 
LVL 1

Author Comment

by:olisaac
ID: 2663265
Hi,

Thanks, it works.

But I have another question (reason for the increase of the points).

When I push the button, in my Delphi code I want to make integrity tests on text box (in the html page too (TITRE In my sample code)).
If the data is not good in this text box. I would that the page HTML don't change to permit to the user to correct his mistake

I've to change the value of the handle in the beforedispatch or afterdispatch function

I don't know if my question is so clear...

Olivier

Sample of my code :

procedure TWebModule1.WebModuleBeforeDispatch(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
  if (Request.ContentFields.Values['ADD'] <> '') then
    begin

    if length(Titre1) > 50 then
      begin
        MessageDlg('TITRE NOT CORRECT', mtInformation, [mbOk], 0);
        exit;
      end;
end;
0
 
LVL 1

Author Comment

by:olisaac
ID: 2669108
Hi geobul, if you answer my second question, the points are for you...
0
 
LVL 17

Accepted Solution

by:
geobul earned 75 total points
ID: 2672346
Hi,

I'm sorry for the late reply. I was on a trip for a few days.

You can NOT use any visual component in the CGI program (MessageDlg in your code).
 
In this case I send an 'error' page (plain text, no links or buttons), where I describe what kind of error it is and ask the user to press BACK button himself.

-----------
<HTML>
<HEAD><TITLE>ERROR</TITLE></HEAD>
<BODY>
<B>Error !</B> Description follows:<HR>
Bla bla<HR>
Press <STRONG>BACK</STRONG> to continue !
</BODY>
</HTML>
---------------
or you can use a button on the page above this way:
<INPUT TYPE=submit NAME="OKBtn" VALUE="OK" OnClick="history.go(-1);return true;">

Pressing the button will go back.

Delphi code can be:

procedure TWebModule1.WebModuleBeforeDispatch(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
  sError : String;
begin
  sError := ''; { Empty string }
  if (Request.ContentFields.Values['ADD'] <> '') then  begin
    if length(Titre1) > 50 then begin
        sError := 'TITRE NOT CORRECT';
    end else begin
      if .... then begin { Another check }
         sError := 'Error description';
      end;
    end;
  end;
  if sError <> '' then begin
    Response.Content := '<HTML><HEAD><TITLE>ERROR</TITLE></HEAD><BODY> <B>Error !</B> Description follows:<HR>' + sError + '<HR> Press <STRONG>BACK</STRONG> to continue ! </BODY> </HTML>';
    Handled := True;
    Response.SendResponse;
  end;
end;

Regards, Geo
0
 
LVL 1

Author Comment

by:olisaac
ID: 2682957
I will have some other questions for you in a few days...
0
 
LVL 17

Expert Comment

by:geobul
ID: 2683114
I will be happy to help !
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
find a node in VST 2 93
enhance the following code 3 54
Microsoft Access 97 and Delphi XE2 9 85
How to insert .png images to TClientDataSet .cds file? 2 86
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

752 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