Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Declairing Variables in Behaviors with ASP VBScript

Guest
Jan 26, 2009 Jan 26, 2009
Ok, I don't know if this is a problem outside of VBScript, so maybe this issue is just there. When you declair variables in VBScript, you can't declair the same variable name twice. If you do, you get an error.

So, problem is, if I insert an Update, Insert and/or Delete behavior on the same page, the code generated by DW declairs common variable. So when you run the page, you get that declaration error message.

I normally just go in the code and comment out all but the first instance of the declaration. That works fine, but then the behavior dissapears from the Behaviors Panel. Ok, so that's not really a big problem because I hand code them easy enough.

Nevertheless, I like the behaviors listed, if nothing else, so I can see a summary of what behaviors I have defined in the page. Especially if it is a page I haven't messed with ina while.

Is there any work around for this? I haven't tried going in and editing the behavior. Maybe somehow I could do that and just delete the common declarations? Any ideas?
TOPICS
Server side applications
945
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

People's Champ , Jan 27, 2009 Jan 27, 2009
Translate
LEGEND ,
Jan 26, 2009 Jan 26, 2009
I think you have found the workaround. Dreamweaver wasn't designed to =
have more than one Insert, Update or Delete behavior on a page. As you =
have found out, it errors. The workaround is to create a page that does =
each of what you need and then combine them so there is one variable =
declaration, etc. and using an If then type arrangement to run one or =
the other.

But as you have found out, it won't be listed in the server behaviors =
anymore. That doesn't mean invalid code. It just means Dreamweaver =
doesn't recognize code that it didn't write.

The alternative would be to put them in separate pages, which was how =
they were created to be used.


--=20
Nancy Gill
Adobe Community Expert
Author: Dreamweaver 8 e-book for the DMX Zone
Co-Author: Dreamweaver MX: Instant Troubleshooter (August, 2003)
Technical Editor: Dreamweaver CS3: The Missing Manual,
DMX 2004: The Complete Reference, DMX 2004: A Beginner's Guide
Mastering Macromedia Contribute
Technical Reviewer: Dynamic Dreamweaver MX/DMX: Advanced PHP Web =
Development

"ITLogic" <webforumsuser@macromedia.com> wrote in message =
news:gllf0n$ads$1@forums.macromedia.com...
> Ok, I don't know if this is a problem outside of VBScript, so maybe =
this issue=20
> is just there. When you declair variables in VBScript, you can't =
declair the=20
> same variable name twice. If you do, you get an error.
>=20
> So, problem is, if I insert an Update, Insert and/or Delete behavior =
on the=20
> same page, the code generated by DW declairs common variable. So when =
you run=20
> the page, you get that declaration error message.
>=20
> I normally just go in the code and comment out all but the first =
instance of=20
> the declaration. That works fine, but then the behavior dissapears =
from the=20
> Behaviors Panel. Ok, so that's not really a big problem because I hand =
code=20
> them easy enough.
>=20
> Nevertheless, I like the behaviors listed, if nothing else, so I can =
see a=20
> summary of what behaviors I have defined in the page. Especially if it =
is a=20
> page I haven't messed with ina while.
>=20
> Is there any work around for this? I haven't tried going in and =
editing the=20
> behavior. Maybe somehow I could do that and just delete the common=20
> declarations? Any ideas?
>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 27, 2009 Jan 27, 2009
That's what I figured, thanks for the reply. Maybe that's something for the Adobe peeps to work on for future versions. Wih the whole AJAX thing, like their own SPRY library, it's not uncommon to have multiple forms and database functions on one page enclosed in a tabbed panel or sliding panel or something.

So, I see 3 solutions:

1) The way I'm doing it and losing the behavior from the list.

2) Make each function a seperate page which would be listed as the action for each form. Then, I would have pages out the ying yang for a complicated database administration page.

3) Do some sort of If Then Else or Select Case thing as you mentioned. In that case I will lose the behavior from the list as well because I hand coded the function.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 27, 2009 Jan 27, 2009
ITLogic wrote:
> That's what I figured, thanks for the reply. Maybe that's something for the
> Adobe peeps to work on for future versions. Wih the whole AJAX thing, like
> their own SPRY library, it's not uncommon to have multiple forms and database
> functions on one page enclosed in a tabbed panel or sliding panel or something.
>
> So, I see 3 solutions:
>
> 1) The way I'm doing it and losing the behavior from the list.
>
> 2) Make each function a seperate page which would be listed as the action for
> each form. Then, I would have pages out the ying yang for a complicated
> database administration page.
>
> 3) Do some sort of If Then Else or Select Case thing as you mentioned. In that
> case I will lose the behavior from the list as well because I hand coded the
> function.

If your using AJAX then you will want a separate page for each function,
then call that single page via AJAX on the main page. Since AJAX wont
refresh, it will just appear to have done it all on the one page.

I am looking at SPRY to do just this at the moment, and has lots of
possibilities. Download it from the Adobe website and follow the samples
and articles, all looks good.

Dooza
--
Posting Guidelines
http://www.adobe.com/support/forums/guidelines.html
How To Ask Smart Questions
http://www.catb.org/esr/faqs/smart-questions.html
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 27, 2009 Jan 27, 2009
Oh wow! I didn't even think to use AJAX for that. I am currently using tabbed panels in SPRY with a form on each panel that does databse functions. I can tab through panels without refreshing the page because it's all on one page with AJAX.

But, when I update and re-read from the database I refresh. I never thought to use SPRY to call the databes functions, I was just using the VBScript redirect generated by Dreamweaver.

Thanks for the tip, I will look into that as well! Hopefully that will solve a big problem I have. I created some look-up tables. When you select a main catagory from the first drop-down, it refreshes and populates the second drop-down with sub catagories of that main catagory. Works fine for now, but I forsee a major problem brewing. If someone is filling in a form, but hasn't submitted it, they will lose all the data in the fields after a refresh to get the sub-catagories.

If SPRY can handel that without a refresh it would be fantastic!!!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jan 27, 2009 Jan 27, 2009
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 27, 2009 Jan 27, 2009
Ok, I have a quick question. I'm not at my computer to test, otherwise I would and find this out for myself.

The AJAX submit method always responds back to the current page right? So if I want to go to a different page, like after successful credentials on a login page, then I would still use the good old fashion redirect correct?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 27, 2009 Jan 27, 2009
LATEST
ITLogic wrote:
> Ok, I have a quick question. I'm not at my computer to test, otherwise I would
> and find this out for myself.
>
> The AJAX submit method always responds back to the current page right? So if I
> want to go to a different page, like after successful credentials on a login
> page, then I would still use the good old fashion redirect correct?

Yes, that sounds right to me. But maybe you could just stay on the same
page, but hide the logon form and display a logged on message instead?

Dooza
--
Posting Guidelines
http://www.adobe.com/support/forums/guidelines.html
How To Ask Smart Questions
http://www.catb.org/esr/faqs/smart-questions.html
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 27, 2009 Jan 27, 2009
WOW! This is fantastic! I'm sure this is old news to you guys, but it's new to me. I'll check out those links right now.

All you guys and girls go get a beer, martini or whatever and tell them to put it on my tab. hee heee
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines