Hello All,
I am dynamically adding a Button web server control to my page with the
following code:
Dim btnView As New Button
btnView.Text = " View Form "
btnView.Attributes.Add("onClick", "javascript:ShowPdfWindow()")
AddHandler btnView.Click, AddressOf ShowPdf
plcButtons.Controls.Add(btnView)
ShowPdfWindow is defined in a script tag in the web page's <head> section.
The code does what I want it to do, except for one thing: the client script
(ShowPdfWindow) executes before the server code (ShowPdf).
Is there a way for me to reverse the order of execution?
TIA,
--
Joe 4 1466
Yes and no. Not at all the way you are doing it.
You need to remove the client-Side on click. And during the server-side
event handler, output the javascript that you want (likely using
Page.RegisterStartupScript).
This will make your page postback, your server side handler to be processed,
the response to be output including the javascript you want.
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/
"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:AB**********************************@microsof t.com... Hello All,
I am dynamically adding a Button web server control to my page with the following code:
Dim btnView As New Button btnView.Text = " View Form " btnView.Attributes.Add("onClick", "javascript:ShowPdfWindow()") AddHandler btnView.Click, AddressOf ShowPdf plcButtons.Controls.Add(btnView)
ShowPdfWindow is defined in a script tag in the web page's <head> section.
The code does what I want it to do, except for one thing: the client script (ShowPdfWindow) executes before the server code (ShowPdf).
Is there a way for me to reverse the order of execution?
TIA, -- Joe
Thanks Karl.
Are you aware of a sample of this somewhere?
--
Joe
"Karl Seguin [MVP]" wrote: Yes and no. Not at all the way you are doing it.
You need to remove the client-Side on click. And during the server-side event handler, output the javascript that you want (likely using Page.RegisterStartupScript). This will make your page postback, your server side handler to be processed, the response to be output including the javascript you want.
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/
"Joe" <Jo*@discussions.microsoft.com> wrote in message news:AB**********************************@microsof t.com... Hello All,
I am dynamically adding a Button web server control to my page with the following code:
Dim btnView As New Button btnView.Text = " View Form " btnView.Attributes.Add("onClick", "javascript:ShowPdfWindow()") AddHandler btnView.Click, AddressOf ShowPdf plcButtons.Controls.Add(btnView)
ShowPdfWindow is defined in a script tag in the web page's <head> section.
The code does what I want it to do, except for one thing: the client script (ShowPdfWindow) executes before the server code (ShowPdf).
Is there a way for me to reverse the order of execution?
TIA, -- Joe
All you would do is in your server-side event handler for the button do:
Page.RegisterStartupScript("ShowPdfWindow", "<script
language=""JavaScript"">" & System.Environment.NewLine & "ShowPdfWindow();"
& System.Environment.NewLine & "</script>")
if you are using 2.0, that's deprecated in favor of
Page.ClientScript.RegisterStartupScript with some slighly different
overloads..
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/
"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:BD**********************************@microsof t.com... Thanks Karl.
Are you aware of a sample of this somewhere? -- Joe
"Karl Seguin [MVP]" wrote:
Yes and no. Not at all the way you are doing it.
You need to remove the client-Side on click. And during the server-side event handler, output the javascript that you want (likely using Page.RegisterStartupScript). This will make your page postback, your server side handler to be processed, the response to be output including the javascript you want.
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/
"Joe" <Jo*@discussions.microsoft.com> wrote in message news:AB**********************************@microsof t.com... > Hello All, > > I am dynamically adding a Button web server control to my page with the > following code: > > Dim btnView As New Button > btnView.Text = " View Form " > btnView.Attributes.Add("onClick", "javascript:ShowPdfWindow()") > AddHandler btnView.Click, AddressOf ShowPdf > plcButtons.Controls.Add(btnView) > > ShowPdfWindow is defined in a script tag in the web page's <head> > section. > > The code does what I want it to do, except for one thing: the client > script > (ShowPdfWindow) executes before the server code (ShowPdf). > > Is there a way for me to reverse the order of execution? > > TIA, > -- > Joe
Thank you.
--
Joe
"Karl Seguin [MVP]" wrote: All you would do is in your server-side event handler for the button do:
Page.RegisterStartupScript("ShowPdfWindow", "<script language=""JavaScript"">" & System.Environment.NewLine & "ShowPdfWindow();" & System.Environment.NewLine & "</script>")
if you are using 2.0, that's deprecated in favor of Page.ClientScript.RegisterStartupScript with some slighly different overloads..
Karl -- MY ASP.Net tutorials http://www.openmymind.net/
"Joe" <Jo*@discussions.microsoft.com> wrote in message news:BD**********************************@microsof t.com... Thanks Karl.
Are you aware of a sample of this somewhere? -- Joe
"Karl Seguin [MVP]" wrote:
Yes and no. Not at all the way you are doing it.
You need to remove the client-Side on click. And during the server-side event handler, output the javascript that you want (likely using Page.RegisterStartupScript). This will make your page postback, your server side handler to be processed, the response to be output including the javascript you want.
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/
"Joe" <Jo*@discussions.microsoft.com> wrote in message news:AB**********************************@microsof t.com... > Hello All, > > I am dynamically adding a Button web server control to my page with the > following code: > > Dim btnView As New Button > btnView.Text = " View Form " > btnView.Attributes.Add("onClick", "javascript:ShowPdfWindow()") > AddHandler btnView.Click, AddressOf ShowPdf > plcButtons.Controls.Add(btnView) > > ShowPdfWindow is defined in a script tag in the web page's <head> > section. > > The code does what I want it to do, except for one thing: the client > script > (ShowPdfWindow) executes before the server code (ShowPdf). > > Is there a way for me to reverse the order of execution? > > TIA, > -- > Joe This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: yfng |
last post by:
In a web form, I want the user clicks on one button and this button will
trigger another button/link which will open a new browser window? How to do
that? Is there any method like...
|
by: ewitkop90 |
last post by:
Here is my code:
<SCRIPT>
function transportchange(transport) {
if (framenewinstall.Helpdesk.checked)
framenewinstall.Helpdesk.checked=false;
if (framenewinstall.CircuitNumber.checked)...
|
by: IntraRELY |
last post by:
I am using the following command to launch and .NET VB Executable, which is
a simple Windows Form (printCheckClient.exe). I am using a HyperLink Control
and works perfect....
|
by: C |
last post by:
Hi,
I have a server side asp.net button on a web page.
On clicking the button I want to call some Javascript.
Can I not simply do a onclick="MyJavascript();" or is it necessary that I add...
|
by: Sedef |
last post by:
Hi,
i'm trying to create a custom Button user control which will be derived from System.Web.UI.WebControls.Button. the normal server side Button class creates some client side javascript code for...
|
by: vcornjamb |
last post by:
Hello, I am developing a web form that contains some buttons and a data grid
which has as its last column link buttons that will delete the data
associated
with that row. Everything works fine,...
|
by: Samy |
last post by:
Hi There,
I have a label in a datagrid which I make it a input type = radio in
ItemDataBound so that radio buttons are shown in the datagrid.
This is how I have it...
ASPX...
<asp:Label...
|
by: Jay |
last post by:
I am on the 2.0 framework and have run the c:\windows\microsoft.net
\framework\v1.1.4322\aspnet_regiis.exe -c and had no success. About
half of the buttons on my webforms are firing and the other...
|
by: Nick Verlinden |
last post by:
Hi there,
i'm trying to accomplish the following (however searching the net for days now, without result):
As you know you have a asp button:
<asp:Button ID="test" Text="Test"...
|
by: =?Utf-8?B?ZWdzZGFy?= |
last post by:
Hello, i have implemented a button in some other pages that calls another
one, the problem is that everytime I hit the button he goes for the postback
code and I already disable that part. this is...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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,...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
|
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,...
|
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...
| |