This topic is locked

Custom Button to open a page

12/10/2009 9:34:12 AM
ASPRunnerPro General questions
Stu author

I have a record with a view page that I'd like to go to from a list page by pressing a button. Allowing ASPRunner to create a Smarty link to it gives me one link per record in the list and its always going to be going to a record with the same masterkey for that list.
The view page url is "http://localhost/V24ExperimentWithThreadAudit/WebAuditView_list.asp?mastertable=dbo%2EWebChat&masterkey1=54"; and I could write the code to substitute the correct key value replacing "54".
I guess I do something as a Code Snippet from the List form but I don't know how to create a button to activate the code.

J
Jane 12/11/2009

Hi,
use List page: After record processed event to form correct link. Here is a sample:

record("custom_link") = "href=""http://localhost/V24ExperimentWithThreadAudit/WebAuditView_list.asp?mastertable=dbo%2EWebChat&masterkey1="; & data("FieldName") & """"



Then use following link on the Visual Editor tab:

<a {$custom_link}>
Stu author 12/16/2009

Jane,
Thanks. I did it a slightly different way, inspired by your Post on Next & Previous buttons. Hope you don't mind if I explain the steps for the benefit of others.
In Visual Editor I copied an ASP Generated "Add New" Button and pasted it where I wanted my new button to be. I selected the pasted button and went into HTML design mode.
This gave me HTML like this:-
<INPUT class=button style="WIDTH: 124px; HEIGHT: 20px" type=button size=71 value="See Thread List" {$Newaction}>
I changed the Button text to "See Thread List" and named the button with {$Newaction}
Since I could get to the Page I wanted to View by the links in the previous page so I generated my web and pressed that link to generate the correct URL model I would need to provide programmatically. In my case I got:-
http://localhost/V25ExperimentWithThreadAudit/WebThreadView_list.asp?mastertable=dbo%2EWebChat&masterkey1=53
However, since its website relative the only part I need is:-
WebThreadView_list.asp?mastertable=dbo%2EWebChat&masterkey1=53

  • where 53 happened to be the master key on the link I pressed.
    To reach this page from the preceding List page by pressing the button I need to add some code to the "List Page.Before Display" event.
    My code is:-
    str = "<input type=button class=button value=Newaction onclick=""window.location.href='WebThreadView_list.asp?mastertable=dbo%2EWebChat&masterkey1=" & Session("LINK") &"';"">"
    xt.assign "Newaction",str
    "Session("LINK") happens to be the Master key I saved in the page before I jumped to the List View. The List View Master Key is the same for all items in the List. What the code does is complete the URL string with the correct Key value (instead of 53).
    The xt.assign addresses the tag name used for the button and assigns the format string to it. Viola!
    The ONLY change one should make here is that the str string definition of the Button in code is different from the definition in the Visual View, Ideally it should be an exact match in terms of position and size parameters.
    Regards,
    Stu