I have a server side button that needs to do some preperation and
afterwards, if everything goes well, open a new browser with a specific
url.
I know how to execute javascript from a server side control, adding the
javascript to the attributes. I need to open the browser window AFTER
the code behind event is finished.
For example I have two text boxes on the form, whose values I want to
send as parameters to the URL that I want to open on server side button
click. I wrote code to add attributes to that button Onclick. What
happens is when I click on the button, it is adding attribute to that
button. The second click is opening the new browser. But I want to open
the new browser on first click.
Is there any way to accomplish this?
Thanks,
Shil. 6 21387
Hi Shil,
If i have understood your problem correctly, this is how you can do it,
Add the attributes for the button on the page load.
page_load()
button1.attributes.add("abcd","abcd");
now when you click the button, call the open method of the Javascript by
passing a URL along with the values in the text box as query string.
something like this.
button1_click()
Response.write(<script>window.open('pass the url with Query string
values')</string>
This will open a new window, you can also set the size and all features of
the new window exactly the way you do with the window.open.
Hope this was helpful to you.
Thanks,
--
Kannan.V
Home : http://www.kannanv.com
Blog : http://kannanv.blogspot.com
Web : http://www.DotnetLounge.net
"Any one who has never made a mistake has never tried anything new" - Einstein
"shil" wrote: I have a server side button that needs to do some preperation and afterwards, if everything goes well, open a new browser with a specific url.
I know how to execute javascript from a server side control, adding the javascript to the attributes. I need to open the browser window AFTER the code behind event is finished.
For example I have two text boxes on the form, whose values I want to send as parameters to the URL that I want to open on server side button click. I wrote code to add attributes to that button Onclick. What happens is when I click on the button, it is adding attribute to that button. The second click is opening the new browser. But I want to open the new browser on first click.
Is there any way to accomplish this?
Thanks, Shil.
shil,
you can use RegisterStartUpScript to call the script to open winodw on page
start up..
Sample code is like below .. add this code in button click event in code
behind
string jscript = ""<script>";
jscript += "winodw.open('yoururl.aspx?text1="+ TextBox1.Text + "&text2=" +
TextBox2.Text + "')"
jscript += "</script>";
Page.RegisterStartUpScript("open", jscript );
HTH
"shil" wrote: I have a server side button that needs to do some preperation and afterwards, if everything goes well, open a new browser with a specific url.
I know how to execute javascript from a server side control, adding the javascript to the attributes. I need to open the browser window AFTER the code behind event is finished.
For example I have two text boxes on the form, whose values I want to send as parameters to the URL that I want to open on server side button click. I wrote code to add attributes to that button Onclick. What happens is when I click on the button, it is adding attribute to that button. The second click is opening the new browser. But I want to open the new browser on first click.
Is there any way to accomplish this?
Thanks, Shil.
That is exactly what I was looking for. Thank you very much Kannan.
Worked great!!
I have done this by registering a using a placeholder control in the web
page for script that I add only when postback is performed.
In the server side button control event handler, place the script into the
placeholder control on the server side. Thus, when the page posts back, the
JavaScript can execute to open a new window. If you don't want the script
to be remembered on each postback, then set EnableViewState = false for the
placeholder control.
--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.
EmailID = varnk
Domain = Diebold.com
-----------------------------------
"shil" <jo******@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com... I have a server side button that needs to do some preperation and afterwards, if everything goes well, open a new browser with a specific url.
I know how to execute javascript from a server side control, adding the javascript to the attributes. I need to open the browser window AFTER the code behind event is finished.
For example I have two text boxes on the form, whose values I want to send as parameters to the URL that I want to open on server side button click. I wrote code to add attributes to that button Onclick. What happens is when I click on the button, it is adding attribute to that button. The second click is opening the new browser. But I want to open the new browser on first click.
Is there any way to accomplish this?
Thanks, Shil.
of course popup blockers (xp-sp2), prevent this code from working.
-- bruce (sqlwork.com)
"shil" <jo******@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com... That is exactly what I was looking for. Thank you very much Kannan. Worked great!!
I agree with you Bruce.
But is there any other way to open a new window with out using
Javascript?
Thanks,
Shil. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Shamin |
last post by:
Hi,
Thanks in advance for answering to my Question. I'm stuck with this
problem and would really appreciate any help.
I have 2 aspx files (Main.aspx and ReportViewer.aspx). Main.aspx has a...
|
by: hb |
last post by:
Hi,
I have a asp:button btnGo. When clicking this button,
the code will parse a asp:table to find a specific ID
under certain conditions. Once the ID is found, the code
need to keep the current...
|
by: Dan |
last post by:
hello all,
is there a way to open a new window without javascript and a href=_blank?
i need to connect a button click with some lines of code and then, a new
window shall get opened.
but i didn't...
|
by: ACaunter |
last post by:
Hi all,
I'm having a little problem here.. my code is:
Session("test") = Button46.Text
Button46.Attributes.Add("Onclick", "opennewpage()")
i have this code inside the button click, which means...
|
by: buran |
last post by:
Dear ASP.NET Programmers,
I am using the following code block to navigate to the invoice page of my
app. when users click on the button btnInvoice. However, I want to display
the invoice page in...
|
by: nashak |
last post by:
Hello,
I have a aspx page on which I have a button. In the click event method
in code-behind I do some processing and now need to open a new window
in another browser and pass a couple of...
|
by: Guy Cohen |
last post by:
Hi all
How do I show an existing aspx page to the user?
I need an equivalent command to java's window.open in ASP.NET
TIA
Guy
|
by: bushi |
last post by:
hi everyone!
i have diplayed my hyperlinks in a iframe.when i redirect
to next page.the next page also open in the same frame,but i want to
open a new browser window,when i click on the...
|
by: H. Rodriguez |
last post by:
Hello,
I would like to be able to open a new IE window on the client side and
display a PDF document in the new window. Many tutorial sites that I have
checked suggest opening a new IE window...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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...
| |