Register Blogs FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read

Go Back   DeveloperBarn Forums > Programming & Scripting > JavaScript Programming

Sponsored Links

Discuss "Alert and close advice" in the JavaScript Programming forum.

JavaScript Programming - Javascript is a cross-browser client-side scripting language. Discuss Javascript and AJAX related scripts here.


Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old June 20th, 2008, 10:01 AM
Rebelle's Avatar
Barn Enthusiast
 
Join Date: Mar 2008
Posts: 255
Thanks: 48
Thanked 1 Time in 1 Post
Rep Power: 1
Rebelle is on a distinguished road
Question Alert and close advice

Hi All,

I have hyperlink for a recordset on my TestResults page like below, if records are returned it opens the page and displays page BOMResults in a new window:
Code:
<TD align=right><a href="//server/test/BOMResults.asp?ItemID=<%=rs("ItemID")%>" target="_blank"><%=rs("ItemDesc")%></a> &nbsp;</TD>
When no records to be displayed, I've added this after my sql statement on TestResults page to get an alert and close new window.

Code:
If rs.EOF then
%>
<SCRIPT LANGUAGE="javascript">

alert('No BOM for your selection!');

window.close() 

</SCRIPT>
<%
  Response.End
End If
%>
Question, is this the best way to do the alert when no records are returned? When I click the link for something that doesn't have any records, I get the alert but it also tries to open page (server/test/BOMResults.asp?ItemID=<%=rs("ItemID")%>) which does close when i click OK on the alert. On screen new window is behind the alert. Just wondering.....Thanks!
Reply With Quote
Sponsored Links
  #2  
Old June 20th, 2008, 10:08 AM
Wolffy's Avatar
Slaprentice of Wolves
 
Join Date: Mar 2008
Location: Peoria, IL
Posts: 175
Thanks: 3
Thanked 24 Times in 21 Posts
Rep Power: 1
Wolffy is on a distinguished road

Awards Showcase
Microsoft .Net 
Total Awards: 1

Default

Rather than use a JS alert -- why not build the page so it displays a friendly NO Records Found message in place of the usual results?
__________________
Wolffy
------------------------
Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Rework for your specific environment may be required. Void where prohibited by law. Not valid in California. Your mileage may vary.
Reply With Quote
The Following User Says Thank You to Wolffy For This Useful Post:
Rebelle (June 20th, 2008)
  #3  
Old June 20th, 2008, 10:11 AM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 863
Thanks: 20
Thanked 78 Times in 75 Posts
Blog Entries: 5
Rep Power: 3
jmurrayhead is a jewel in the roughjmurrayhead is a jewel in the roughjmurrayhead is a jewel in the rough

Awards Showcase
Microsoft Windows Microsoft SQL Server Microsoft .Net Classic ASP 
Total Awards: 4

Default

I agree with Wolffy. JavaScript alerts are kind of tacky... and what happens if a user has a browser that either does not support JavaScript or has JavaScript turned off?
__________________
jmurrayhead
If you agree with me... click the icon!
If my post solved your problem, click the button in the lower right-hand corner of the post.

If you like it here...throw us a few bones to help
support us.

Join our Folding team: DeveloperBarn Folding
Reply With Quote
  #4  
Old June 20th, 2008, 10:20 AM
Wolffy's Avatar
Slaprentice of Wolves
 
Join Date: Mar 2008
Location: Peoria, IL
Posts: 175
Thanks: 3
Thanked 24 Times in 21 Posts
Rep Power: 1
Wolffy is on a distinguished road

Awards Showcase
Microsoft .Net 
Total Awards: 1

Default

[set offtopic on]
Which begs the question I've never had the time (pronounced gumption) to research. Since ASP.NET makes extensive use of Javascript -- what if the client has JS turned off?
Reply With Quote
  #5  
Old June 20th, 2008, 10:23 AM
Rebelle's Avatar
Barn Enthusiast
 
Join Date: Mar 2008
Posts: 255
Thanks: 48
Thanked 1 Time in 1 Post
Rep Power: 1
Rebelle is on a distinguished road
Default

Sorry just want to make sure I understand completely....

so I took out the javascript and replaced it with this:

Code:
Response.Write "No Records Found!"
Using this way, It opens the new window and shows No Records Found, which is good. but any way to let the user know No Records Found without opening the new window?

Thanks again!
Reply With Quote
  #6  
Old June 20th, 2008, 10:23 AM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 863
Thanks: 20
Thanked 78 Times in 75 Posts
Blog Entries: 5
Rep Power: 3
jmurrayhead is a jewel in the roughjmurrayhead is a jewel in the roughjmurrayhead is a jewel in the rough

Awards Showcase
Microsoft Windows Microsoft SQL Server Microsoft .Net Classic ASP 
Total Awards: 4

Default

Quote:
Originally Posted by Wolffy View Post
[set offtopic on]
Which begs the question I've never had the time (pronounced gumption) to research. Since ASP.NET makes extensive use of Javascript -- what if the client has JS turned off?
I think some things will stop working, like the LinkButton, but other than that, everything will be run server-side.
Reply With Quote
  #7  
Old June 20th, 2008, 10:25 AM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 863
Thanks: 20
Thanked 78 Times in 75 Posts
Blog Entries: 5
Rep Power: 3
jmurrayhead is a jewel in the roughjmurrayhead is a jewel in the roughjmurrayhead is a jewel in the rough

Awards Showcase
Microsoft Windows Microsoft SQL Server Microsoft .Net Classic ASP 
Total Awards: 4

Default

Quote:
Originally Posted by Rebelle View Post
Sorry just want to make sure I understand completely....

so I took out the javascript and replaced it with this:

Code:
Response.Write "No Records Found!"
Using this way, It opens the new window and shows No Records Found, which is good. but any way to let the user know No Records Found without opening the new window?

Thanks again!
Of course...just don't put it in a popup window, of course
Reply With Quote
  #8  
Old June 20th, 2008, 10:25 AM
Wolffy's Avatar
Slaprentice of Wolves
 
Join Date: Mar 2008
Location: Peoria, IL
Posts: 175
Thanks: 3
Thanked 24 Times in 21 Posts
Rep Power: 1
Wolffy is on a distinguished road

Awards Showcase
Microsoft .Net 
Total Awards: 1

Default

Hmm..you would want the user to stay on the current page if the posted page has no data to display? Is that what you are looking for?
Reply With Quote
  #9  
Old June 20th, 2008, 10:38 AM
Rebelle's Avatar
Barn Enthusiast
 
Join Date: Mar 2008
Posts: 255
Thanks: 48
Thanked 1 Time in 1 Post
Rep Power: 1
Rebelle is on a distinguished road
Default

Yes, TestResults page has the link, when the link is clicked, if records are returned it displays the BOMResults in a new window (so both pages stay open) but if no records, just notify there are no records (TestResults stays open).
Reply With Quote
  #10  
Old June 20th, 2008, 11:24 AM
Wolffy's Avatar
Slaprentice of Wolves
 
Join Date: Mar 2008
Location: Peoria, IL
Posts: 175
Thanks: 3
Thanked 24 Times in 21 Posts
Rep Power: 1
Wolffy is on a distinguished road

Awards Showcase
Microsoft .Net 
Total Awards: 1

Default

OK, I was looking for some code that did this, but I must have deleted it. What I was thinking was this. If your BOMresults page finds no records, it can execute a JS function in the TestResults page that could (for example) display the No Records Found alert and then just close. The visual result being that BOMResults just goes away.

It was the snippet that does 'execute a JS function in the [opening] page' that I can't find.
Reply With Quote
Reply

  DeveloperBarn Forums > Programming & Scripting > JavaScript Programming

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -4. The time now is 02:32 PM.



Content Relevant URLs by vBSEO 3.2.0