CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Dynamic Page Title

Print topic Send  topic

Author Message
Bubba

Posts: 33
Posted: 07/01/2004, 8:32 PM

Hi,

I know this can be done in straight ASP, but I cannot figure it out in CodeCharge.

I want the web page title (<Title> </Title>) to dynamically display a field from a table in the database.

In normal ASP I would do something like this:

<%

' Create Objects
Set Conn = Server.CreateObject("ADODB.Connection")

'Open the Connection
Conn.Open SQLDSN, SQLUser, SQLPassword

' Get Values
Product_Id = Request.QueryString("Product_Id")


sql="SELECT Product_Title, Product_Description, Product_Price " &_
"FROM tblProduct " &_
"WHERE Product_Id=" & Product_Id
Set RS = Conn.Execute(sql)

Title = RS("Product_Title")
Description = RS("Product_Description")
Price = RS("Product_Price")

RS.close
Conn.Close
%>

<HTML>
<HEAD>
<TITLE><%=Title%></TITLE>
</HEAD>

However, CodeCharge puts ASP code and HTML code in two different spots!! So does anyone know how I can get CodeCharge to let me use dynamic titles in my web (asp) pages?

I use:
CodeCharge Studio 2.2
Access2000
IE6
Win 2k

Thanks!
View profile  Send private message
zolw


Posts: 51
Posted: 07/01/2004, 9:17 PM

Why dont you try this code Tony Do sent.
It works great!!!!

You can use the set tag function

Now your button is

<Input type="submit" value="Search" name="DoSearch">

Change it to
<Input type="submit" value="{AVALUE}" name="DoSearch">

Then in the before show page event or before show record event

<code>
HTMLTemplate.SetVar "@AVALUE", "New button value"
</code>

Tell us how did it work. :-)
_________________
Zolw
http://www.xlso.com
View profile  Send private message
peterr


Posts: 5971
Posted: 07/01/2004, 9:39 PM

The most natural way might be to use a Label. Place a label between the <title> tags and set its value as shown at:
http://docs.codecharge.com/studio/html/ProgrammingTechn...CustomHTML.html
http://docs.codecharge.com/studio/html/ProgrammingTechn...ntrolValue.html
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Joe
Posted: 07/06/2004, 10:11 AM

I used this and it worked perfectly

<title>{Product_Title}</title>
Bubba

Posts: 33
Posted: 07/06/2004, 3:59 PM

Thanks Peterr for the quick reply, but unfortunately no joy with your suggestion.

Also thanks to Joe - but this was the first thing I tried b4 I asked here (re: <title>{Product_Title}</title> ).

The problem for me at least seems to be that the labels do not work inside the <head> tag where the title goes.

Joe, would you mind detailing to me how you got it to work?

I appreciate everyone's input on this

Cheers
View profile  Send private message
peterr


Posts: 5971
Posted: 07/06/2004, 11:40 PM

Since there were no other responses let me add that Joe's method works for me flawlessly. I can't even not make it work :-)
I just specified "abc" in the default value of the Label to test it and it worked OK, then I used the Before Show event to set its value dynamically:
Product_Title.Value = "xyz"

A label doesn't know where it is on the page and it must work within <head> and other tags as good as anywhere else.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Joe
Posted: 07/07/2004, 8:40 AM

bubba,
give me an example of the current code you are using.


Thanks
Joe
Bubba

Posts: 33
Posted: 07/08/2004, 4:47 PM

Hi Peter / Joe

First Peter:
Yes, I can and have done this when testing what I wanted to achieve. The problem however is changing the value from a static string eg:"ABC" to "XYZ" is easy and works fine, but what I cannot do is:

  
Function Title_BeforeShow() 'Title_BeforeShow @24-6C54E1E7  
  
'Custom Code @25-73254650  
' -------------------------  
Title.Value = ProductDetail.ProdDescript.Value  
' -------------------------  
'End Custom Code  
  
End Function 'Close Title_BeforeShow @24-54C34B28  
  

ProductDetail.ProdDescript.Value is a dynamic value on a form.

On the HTML page the Title (lable) is left blank.
  
<title>{Title}</title>  
  

So I tried lots of other things

Title.Value = "{ProdDescript}"
and
Title.Value = "Str" & {ProdDescript} & "Str"
and
<title>{ProdDescript}</title>
etc, etc
- no luck.

I could get it to work with my old friend JavaScript - but only on an OnClick:
  
<input class="CobaltFormButton" type="button" value="Show Title" onclick="document.title = '{ProdDescript}'">  

Perhaps this is just not possible?

Cheers

View profile  Send private message
peterr


Posts: 5971
Posted: 07/08/2004, 5:13 PM

I see now what you're doing. Yes, this may not work because the event that handles the Title label happens before & outside of the code that handles the other form that contains the value you need.
But there could be several other approaches:
1. In the Before Show event of the Title label lookup the value from the database that you want to display. See http://docs.codecharge.com/studio/html/ProgrammingTechn...gleDBValue.html and http://docs.codecharge.com/studio/html/Components/Funct...CCGetParam.html , assuming that you may need to lookup a database value based on a URL variable.

2. A more efficient method may be to use the SetVar method:
http://docs.codecharge.com/studio/html/Components/Methods/ASP/SetVar.html
http://docs.codecharge.com/studio/html/Components/Varia...MLTemplate.html
This method is rarely used and we don't have many examples but this is what zolw mentioned here in the 2nd post. In your case the exact code would be: HTMLTemplate.SetVar "@Title","TEST TITLE". This will work even if {Title} is not a label but you simply place the text {Title} anywhere within the HTML.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Bubba

Posts: 33
Posted: 07/08/2004, 7:21 PM

Peter, Joe, zolw,

Thank you all so very much!

Whoooo hoooo, I finally got it happening - but not *exactly* as recommended, so here is my solution in case anyone else wants to know:

On the FORM Before Show Code:
Function MyForm_BeforeShow() 'MyForm_BeforeShow @2-766D68A1  
  
'Custom Code @21-73254650  
' -------------------------  
Dim TitleVar  
  
TitleVar = MyForm.name.Value  
  
HTMLTemplate.SetVar "@Title","Some Text if you want " & TitleVar  
' -------------------------  
'End Custom Code  
  
End Function 'Close MyForm_BeforeShow @2-54C34B28

*Notes: I had to declare a variable "TitleVar" for it to work.
MyForm.name.value - "name" is the field in the database I wanted to show.

On the HTML page:
  
<title>{Title}</title>  

As Peter pointed out: {Title} does not need to be a label. I just typed it directly in as is.

So that's it! Again thanks a million - you guys are great!

Cheers

Bubba :-D
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.