Greetings all -
I am working on a vb .NET asp web application. I have a button that
opens a new page when clicked. It works fine; the problem is when the
user refreshes the original page, the script executes again even
though the button hasn't been clicked.
Here's the sub - the button is a standard ASP button with no
frills...
Protected Sub btnNew_Click(By Val sender As Object, ByVal e As
System.EventArg s) Handles btnNew.Click
Const INSERT_PAGE As String = "AddNewContact. aspx"
Dim URLArg As String = INSERT_PAGE & "?agreement ID=" &
agreementID
ClientScript.Re gisterStartupSc ript(Me.GetType , "popup",
"window.ope n('" & BASEURL & URLArg & "','_blank','me nubar=yes')",
True)
End Sub
This is making me a little crazy - any help would be greatly
appreciated. I've seen that others have had this problem, but can't
find any solution yet...
Thanks!
Danielle 6 1849
rendering inline openwindows is poor design. for this to work, your users
have to turn off their popup blockers. you really shoudl just attach the
javascript to the button, and not do a postback.
anyway to fix your problem, on the page render a request guid in a hidden
field and also store this on the server. when the button is clicked, check to
see if the request has already been processed, if so take some action, else
process as normal, and mark the request as processed.
-- bruce (sqlwork.com)
"Danielle" wrote:
Greetings all -
I am working on a vb .NET asp web application. I have a button that
opens a new page when clicked. It works fine; the problem is when the
user refreshes the original page, the script executes again even
though the button hasn't been clicked.
Here's the sub - the button is a standard ASP button with no
frills...
Protected Sub btnNew_Click(By Val sender As Object, ByVal e As
System.EventArg s) Handles btnNew.Click
Const INSERT_PAGE As String = "AddNewContact. aspx"
Dim URLArg As String = INSERT_PAGE & "?agreement ID=" &
agreementID
ClientScript.Re gisterStartupSc ript(Me.GetType , "popup",
"window.ope n('" & BASEURL & URLArg & "','_blank','me nubar=yes')",
True)
End Sub
This is making me a little crazy - any help would be greatly
appreciated. I've seen that others have had this problem, but can't
find any solution yet...
Thanks!
Danielle
Bruce -
Thanks for the suggestion. I'd rather do this properly but am fairly
new to programming and having to do this outside of my normal role.
Which is to say I've been using code bits I've found on the web a LOT.
When you say attach the javascript to the button I'm not sure what you
mean or how it would be implemented. Can you provide a sample? Please
note that I need to pass a parameter to the page that is loaded on the
button click.
Danielle
Danielle,
Don't attempt to implement it this way - the vast majority of people use
pop-up blockers and it won't work. Windows opening on their own when you
haven't done anything is REALLY REALLY annoying which is why the popup
blocker was invented.
I really don't understand why you're doing it that way in the first
place. If you want a button that opens a window when you click it, just
put the window.open command in the onclick event of that button! Why are
you posting back to the *server* to open a new window client side??
You don't need any server side code for this.
<a href="javascrip t:window.open(< blah>)">open me</a>
Ideally, so that it works in browsers which don't have javascript enabled:
<a href="page.html " target="_blank"
onclick="javasc ript:window.ope n(<blah>); return false;">open me</a>
The return false bit prevents it from opening the window using
javascript AND navigating to the site in the background. If the user has
JS disabled, it will still open in a new window, but you won't be able
to specify the size or position of the new window.
Opening the window using client side code only will also be much quicker
as it won't postback to the server before opening the window.
Nick...
Danielle wrote:
Greetings all -
I am working on a vb .NET asp web application. I have a button that
opens a new page when clicked. It works fine; the problem is when the
user refreshes the original page, the script executes again even
though the button hasn't been clicked.
Here's the sub - the button is a standard ASP button with no
frills...
Protected Sub btnNew_Click(By Val sender As Object, ByVal e As
System.EventArg s) Handles btnNew.Click
Const INSERT_PAGE As String = "AddNewContact. aspx"
Dim URLArg As String = INSERT_PAGE & "?agreement ID=" &
agreementID
ClientScript.Re gisterStartupSc ript(Me.GetType , "popup",
"window.ope n('" & BASEURL & URLArg & "','_blank','me nubar=yes')",
True)
End Sub
This is making me a little crazy - any help would be greatly
appreciated. I've seen that others have had this problem, but can't
find any solution yet...
Thanks!
Danielle
Well, I'm doing it because I really don't know what I'm doing...
<asp:Button ID="btnNew" runat="server" Font-Bold="true" Font-
Names="verdana"
font-size="small" Text="Add New Contact"
onclick="window .open('www.micr osoft.com'); return false;" /
><br /><br />
Give me an error "BC30456: 'window' is not a member of
'ASP.details_as px'." (details.aspx is the name of the page I amt
trying to load).
Danielle wrote:
Well, I'm doing it because I really don't know what I'm doing...
<asp:Button ID="btnNew" runat="server" Font-Bold="true" Font-
Names="verdana"
font-size="small" Text="Add New Contact"
onclick="window .open('www.micr osoft.com'); return false;" /
><br /><br />
Give me an error "BC30456: 'window' is not a member of
'ASP.details_as px'." (details.aspx is the name of the page I amt
trying to load).
You can't (and don't need to) use an asp:Button control for this. It
will be client side function only, so you shouldn't need to use a
server-side control. Just use a normal HTML button or link.
ie
<input type=button onclick="window .open();" value="Click Me" />
The onclick event of an asp:Button control is code to be executed on the
server in VB or C# etc... The onclick event of a normal HTML button is
javascript to be run locally within the browser.
Hope this makes sense!
Nick...
Danielle wrote:
Well, I'm doing it because I really don't know what I'm doing...
<asp:Button ID="btnNew" runat="server" Font-Bold="true" Font-
Names="verdana"
font-size="small" Text="Add New Contact"
onclick="window .open('www.micr osoft.com'); return false;" /
><br /><br />
Give me an error "BC30456: 'window' is not a member of
'ASP.details_as px'." (details.aspx is the name of the page I amt
trying to load).
You can't (and don't need to) use an asp:Button control for this. It
will be client side function only, so you shouldn't need to use a
server-side control. Just use a normal HTML button or link.
ie
<input type=button onclick="window .open();" value="Click Me" />
The onclick event of an asp:Button control is code to be executed on the
server in VB or C# etc... The onclick event of a normal HTML button is
javascript to be run locally within the browser.
Hope this makes sense!
Nick... This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jeremy McPeak |
last post by:
Howdy.
First of all, awesome job on .NET 2.0! Now to my question:
I love Master Pages and the Page.ClientScript; however, I am having trouble
getting the two to play together. I can build a simple .aspx page (no master
page) and add in JavaScript with RegisterClientScriptBlock() with no
problems. However, when I move the same code over to a content page (or a
master page), the client script is not added to the page. Are there other...
|
by: sck10 |
last post by:
Hello,
I have the following sub in a class in my "App_Code" directory. The script
is for setting focus on a particular control, but I get the error,
"Name ClientScript Not declared". Also, I am using MasterPages. How do I
use "ClientScript.RegisterStartupScript" in a class?
Public Shared Sub SetFocusControl(ByVal FocusControl As Control)
Dim Script As New System.Text.StringBuilder
Dim ClientID As String = FocusControl.ClientID
|
by: Alex Maghen |
last post by:
I want to create a C# class where I'll have a bunch of static functions which
will use the ClientScript object to dump out some JavaScript dynamically.
But I can't figure out how to get a hold of the "ClientScript" object in
those other classes. I guess it's that I have to get the current Page object
and work down to the Page's ClientScript object. But I don't know how to do
that either. I tried HttpContext.Current... but that doesn't get...
|
by: Jon Paal |
last post by:
"Page.Clientscript" does not compile in assembly, with the error message "Reference to a non-shared member requires an object
reference". ...
what reference is it looking for ??????
class class1
public sub showimg()
Dim Response As HttpResponse = HttpContext.Current.Response
Dim theImage As New object
|
by: Stan SR |
last post by:
Hi,
I need to place some javascript code at the end of my aspx page.
How can I do that using the ClientScript.RegisterClientScriptBlock ?
Thanks
Stan
| |
by: verci |
last post by:
Hi guys,
I'm using asp.net 2.0, can anybody send me some complete examples on using
ClientScript.RegisterClientScriptInclude and
ClientScript.RegisterClientScriptSource, for registering an external
javascript file (myfile.js) in my ASP page, I have not found any clear or
complete examples, meaning in wich event handler should I put it in
page_load? if I'm using a master page where is the correct place to put it
in?
please any help...
|
by: HockeyFan |
last post by:
My function to get an alert box on the page isn't working.
Instead it puts in the bottom section of the page:
<script type="text/javascript">
<!--
This is a test// -->
</script>
The function is:
public static void MessageAlert_Create(ref System.Web.UI.Page
|
by: Dariusz Tomoñ |
last post by:
Hello,
I'd like to include JS from C# code (ASP.NET 2.0). I'm trying not directly
from i.e. default.aspx.cs code but from a class belonging to DLL, which is
referred in my project.
The code is as follow:
Page.ClientScript.RegisterClientScriptInclude(Page.GetType(),"swfobject.js","swfobject.js");
|
by: Tony |
last post by:
Hi,
I have two questions:
1) With this code, i never see the alert message. Why? How to see it?
Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "myscript", _
" alert('you go to stating page.');", True)
response.redirect("start.aspx", false)
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |