fk_ID read value in server script

This public forum is for user-to-user discussions of ASP.NET Maker. Note that this is not support forum.
Post Reply
MorkvonOrk
User
Posts: 4

fk_ID read value in server script

Post by MorkvonOrk »

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


motfs
User
Posts: 258

Post 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).


MorkvonOrk
User
Posts: 4

Post 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.


motfs
User
Posts: 258

Post 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).


MorkvonOrk
User
Posts: 4

Post 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. ;-)


motfs
User
Posts: 258

Post 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.


Post Reply