This topic is locked
[SOLVED]

passing url parameters

1/23/2023 1:42:01 AM
ASPRunner.NET General questions
R
Rick W author

When using a url with parameters for example:
http://asp_test.com/?serialno=1234

I need to access the serialno value (1234) from the url and use it in a query.
It could be different every time.

It there a way to do that?

admin 1/23/2023
R
Rick W author 1/23/2023

Thank you for the response - I should have explained better.

What I am trying to do is access the serialno from the url and use it in my ASPRunner.NET Event page.

http://asp_test.com/?serialno=1234

SELECT serialno from dbo.example

Will not compile if I use Request.QueryString['serialno'];

R
Rick W author 1/24/2023

I am using Edit Page / After Record Updated to add a History record into another table.

The following code works fine:
dynamic data = XVar.Array();
data ["location"] = values["location"];
data ["user"] = Security.getUserName();
data ["date"] = DateTime.Now.ToString("yyyy MM dd HH:mm:ss");

DB.Insert("dbo.component_history", data);

The problem is I am trying to pass a partno through the URL:
Example: http://11.22.33.44/?partno=7874

Using
data ["partno"] = HttpContext.Request.QueryString["partno"];
I get this error when building
An object reference is required for the non-static field, method, or property.

Using
data ["partno"] = HttpContext.Current.Request.QueryString["partno"];
partno does not have a value

Been fighting this for a few days now but looking to confirm if I can actually do this within the event pages.

R
Rick W author 1/28/2023

Still fighting this problem.

I have a SQL Server with may part numbers.

Want to access one part number by using the URL:
http://mywebsite/?partno=1234

Ideally, would put this in the WHERE statement in SQL.

At a loss as to how to get the partno from the URL and use it within SQL.

admin 1/29/2023

HttpContext.Current.Request.QueryString["partno"] is the right way to access the parameter from the URL however this is just a part of the solution.

  1. You need to pass the parameter to a certain ASPRunner.NET page not just to your website's main URL.


  2. You need to make sure you are using a correct event for this purpose. The best approach is to read this variable from the URL as soon as possible, save it to the session variable and then you can use this session variable in all other events.



R
Rick W author 1/29/2023

It worked!!!
Thank you so much...

Rick