Page 1 of 1

fk_ID read value in server script

Posted: Mon Feb 01, 2016 5:11 am
by MorkvonOrk

How can I get the value of the master ID in a Page Load server script of the detail table.


Re: fk_ID read value in server script

Posted: Mon Feb 01, 2016 10:33 am
by motfs

What do you want to do to get the Master table's key? If you work in Master/Detail relationship, you can get the primary key from the URL (except Add).


Re: fk_ID read value in server script

Posted: Tue Feb 02, 2016 4:38 am
by MorkvonOrk

I want to set default values for the Add Page of the detail table by sql-reading the master-table. For that I need the key (master ID) in my script.
I know it is in the URL but I want it in the code and do not know how.

Thanks.


Re: fk_ID read value in server script

Posted: Tue Feb 02, 2016 5:00 pm
by motfs

In Master/Detail Add or Add page, primary key is not available yet in Page_Load server event. Key will be available after you type (if it is not auto-number key).


Re: fk_ID read value in server script

Posted: Wed Feb 03, 2016 4:44 am
by MorkvonOrk

Found a solution in ASP.NET C#.

Reading the URI works with : HttpContext.Current.Request.Url
To extract the master key in string-format (needed for my next SQL-string):

    string strOrderID = (HttpContext.Current.Request.Url.Query.Split('='))[2];

Not so difficult, after all. ;-)


Re: fk_ID read value in server script

Posted: Wed Feb 03, 2016 10:15 am
by motfs

If the key is in the URL, you can simply use (C#) in Page_Load server event:

string key = ew_Get("key"); // Assume the url is : xxx?key=<keyvalue>

You can use the Build-In function (ew_Get()) in aspxfn*.cs.