This topic is locked
[SOLVED]

 List page Click action or button on page

12/31/2017 10:28:28 AM
ASPRunner.NET General questions
G
georgeb author

ASPRunner.net 9.8 Build 29967 x86

layout = Bootstrap

List page click action

Option 1 - Open Page

Field = Vehicle Title

open URL = http:||localhost:8085|dbo_ResArrStep2|edit?editid1=1151 (hard coded for testing)

how to open = Go To
Browser result (IE and Chrome)

Server Error in '/' Application.

Argument data type text is invalid for argument 1 of rtrim function.



Option 2 - Ajax Snippet using C#

Field = Vehicle Title

Client Before= nothing

Server = MVCFunctions.HeaderRedirect("dbo_ResArrStep2", "edit?editid1=" + String.Format("{0}",1151)); or

MVCFunctions.HeaderRedirect("dbo_ResArrStep2", "edit?editid1=" + String.Format("{0}","1151")); or

MVCFunctions.HeaderRedirect("dbo_ResArrStep2", "edit?editid1=" + String.Format("{0}",XSession.Session["ReservationId"]));
Browser result (IE and Chrome)

Cursor changes to pointing finger but no redirect occurs the list page is still displayed

Option 3 - Ajax Snippet using javascript

Client Before = location.href="http://localhost:8085/dbo_ResArrStep2/edit?editid1=1151"'>http://localhost:8085/dbo_ResArrStep2/edit?editid1=1151";; (hard coded for testing)

return false;

Browser result (IE and Chrome)

Cursor changes to pointing finger but no redirect occurs the list page is still displayed

Client After = location.href="http://localhost:8085/dbo_ResArrStep2/edit?editid1=1151"'>http://localhost:8085/dbo_ResArrStep2/edit?editid1=1151";

Browser result (IE and Chrome)

Cursor changes to pointing finger but no redirect occurs the list page is still displayed

Option 4 - Button on List page

Client Before = location.href = Runner.getPageUrl("dbo_ResArrStep2", "Add"); (selected the "Add" page for testing)

Browser result (IE and Chrome)

Cursor changes to pointing finger but no redirect occurs the list page is still displayed

Client After = location.href = Runner.getPageUrl("dbo_ResArrStep2", "Add"); (selected the "Add" page for testing)

Browser result (IE and Chrome)



The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /dbo_ResArrStep2/Add

Server = MVCFunctions.HeaderRedirect("dbo_Reservations/list");

Browser result (IE and Chrome)

Server error occurred. See details

System.Web.Mvc.RedirectResult

I believe i am using code examples from the manual.
here is the use case

Limo reservation system

user selects one way or roundtrip

display return date and passenger count if round trip (working)

on save redirect to vehicle selection page (working in after add)

system displays list of available vehicles based on passenger count (working)

user either clicks the vehicle name or a "Select" button

on click page is redirected to next step page....(not working)
what am I missing in the redirect? it needs to go to the dbo_ResArrStep2/edit page passing XSession.Session[ReservationId"]
I have tried

MVCFunctions.HeaderRedirect("dbo_ResArrStep2", MVCFunctions.Concat("Edit?Editid1=",XSession.Session["ReservationId"].ToString()));

among many variations to pass the id
TIA

George "Missing something obvious" Benson <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=25254&image=1&table=forumtopics' class='bbc_emoticon' alt=':unsure:' />

jadachDevClub member 12/31/2017

I'm not really sure what you are trying to do, but maybe try something like this:
List Page > Click Actions
Select the ReservationId field and click Run Ajax Snippet and add a new snippet
Client Before:

//Nothing



Server:

dynamic record = XVar.Array();

record = button.getCurrentRecord();

result.InitAndSetArrayItem(record["ReservationId"], "ReservationId");



Client After:

var win = Runner.displayPopup( {

url: "../dbo_ResArrStep2/edit?editid1="+result["ReservationId"],

width: 700,

height: 500,

header: 'Edit Reservation'

});


If you do not want a pop-up, use this in the Client After:

location.href="../dbo_ResArrStep2/edit?editid1="+result["ReservationId"];
G
georgeb author 1/1/2018

That worked thank youI was just looking a the initandsetarrayitem but you've saved me some time.

G

admin 1/2/2018

Server side code of click actions is executed via AJAX. This means that redirects won't work there and yo need to redirect user in ClientAfter event.