TMS Web Core passes parameters via URL

Source: Internet
Author: User



In general, we will pass a URL to the server passed a lot of parameters, through the parameters to determine the corresponding processing, today is about to talk about



If you implement some functionality through URL parameters.



1. Jump into different interfaces via parameters



First we set up a TMS Web core project file.



In addition to the main page, we build two more pages, called the first page and the second page, respectively.












We can go directly to different pages with different URL parameters.



Do some processing in the project file.

var
  s: string;

begin
  Application.Initialize;

  Application.AutoFormRoute: = true;
  Application.MainFormOnTaskbar: = True;

   if HasQueryParam (‘page’, s) then
     begin
     if s = ‘one’ then
            Application.CreateForm (Tonepagef, onepagef);
     if s = ‘two’ then
           Application.CreateForm (TtwopageF, twopageF);

     end
     else
         Application.CreateForm (Tmainf, mainf);

  Application.Run;
end.
Note that the unit WEBLib.WebTools should be added to the uses section.

We now run this example

 

 Without adding parameters, directly display the main page

Let's try it with parameters

You can see that we jump directly to the page we need through the URL parameter.

 

2. Pass parameters to the current page through URL parameters

Put the corresponding control on the main page

Add the corresponding code to the formshow event

procedure Tmainf.WebFormShow (Sender: TObject);
var
  s: string;
begin
      if HasQueryParam (‘arg1’, s) then
          WebLabel2.Caption: = s
        else
          WebLabel2.Caption: = ‘‘ ‘;

      if HasQueryParam (‘arg2‘, s) then
          WebLabel5.Caption: = s
        else
          WebLabel5.Caption: = ‘‘ ‘;

end;
Run this program

Normal display of incoming parameters

 

 Chinese characters can also be processed normally.

Off-topic, because the URL parameter is a very convenient way of SQL injection, so in the actual program processing

When you use URL to spell SQL, you must pay attention to the validity of the input parameters first. You cannot directly use the input parameters to spell SQL.

In addition, use SQL parameters to process input values whenever possible.

 

tms web core passes parameters via URL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.