javascript in c# code behind for window.open()

Hi all,

So I have this code that I am using to pass variables in the query string but also use javascript in order to have a window.open and window.close function on both pages.

string WindowOpen = "window.open('Notes.aspx?NoteTableId=" + id + "&NoteTable=" + Tables.InvoiceHeader + "'); return false;";

linkNoteButton.Attributes.Add("onclick", WindowOpen);

 

My question is where in that string would I implement things such as Heigth and Width of the window being open, also like setting menubar and toolbar = 0 so that those aren't visible when the window opens.  Basically I want to get this functionality with also having the ability to use the query string/varibles.

 window.open ("http://www.javascript-coder.com","mywindow","menubar=1,resizable=1,width=350,height=250");

Thanks a lot!


-1
ajcool123
8/16/2007 5:52:24 PM
asp.net.client-side 24353 articles. 1 followers. Follow

6 Replies
3439 Views

Similar Articles

[PageSpeed] 52

Hi,

You can create function at client side with static info and pass your server side information as parameter.

<script language='javascript>

function x(param y){

 window.open(y,10,200);

}</script>

and on serverside

linkNoteButton.Attributes.Add("onclick", 'javascript:x(PARAM);");

 


- Nikul
Please click "Mark as Answer" on the posts that help you.
-1
nikuldesai
8/16/2007 6:30:25 PM

http://msdn2.microsoft.com/en-us/library/ms536651.aspx

 

You can spcify anything you like in the third paramenter.


Please "Mark as an Answer" if you think my post had helped you!

Thanks.
-1
mpt_fz
8/16/2007 6:37:27 PM

I am confused sort of.  So I shouldn't be doing this with a string, I'm not exactly sure how to specifically pass variables like you are saying

-1
ajcool123
8/16/2007 6:50:47 PM

Here is what I am trying to do.  It compiles however gives me a javascript error.

 

string WindowOpen = "window.open('Notes.aspx?NoteTableId=" + id + "&NoteTable=" + Tables.InvoiceHeader + " '),width=200,height=200,toolbar=no;";

1
ajcool123
8/16/2007 7:07:34 PM

Hi AJ,

Here is the code that will work:

    string WindowOpen = "window.open('Notes.aspx?NoteTableId=" + id + "&NoteTable=" + Tables.InvoiceHeader + "', 'theWin', 'width=200,height=200,toolbar=0,menubar=0');";

  
I recommend you familiarize yourself with String Concatenation in .NET, becuase it is very valuable to understand.

Hope this helps!  Please mark the helpful post(s) as Answer.


Josh Stodola ← Come check out my blog!
1
JoshStodola
8/16/2007 7:11:14 PM

Thank you very much!  that's exactly what I needed :)

-1
ajcool123
8/16/2007 7:46:12 PM
Reply:

Similar Artilces:

C# code behind variable in client side javascript
Is there a way to add a code behind variable to a javascript: window.open command in the NavigateURL or DataNavigateUrlFormatString of Hyperlink Columns and Bound Hyberlink columns? M view post 1039Sushila Bowalekar PatelVisual ASP/ASP.NET MVPhttp://weblogs.asp.net/sushilasb How about inside a plain client side window.open call in javascript? view post 1034Sushila Bowalekar PatelVisual ASP/ASP.NET MVPhttp://weblogs.asp.net/sushilasb Thanks a ton! ...

Javascript confirm message in c# code behind,by clicking ok popup window open
how can i set a confirm javascript message in c# code behind and by clicking ok i have to open a pop up .aspx page. Hello,     Add onclick attribute with javascript function containing window.open() within your c# code. btn.Attributes.Add("onclick", "javascript:window.open('YourPage.aspx')")  Thanks,santosh_maharajaPlease mark as answer if you got expected solution. http://plugins.jquery.com/project/confirm  Cool stuff // The action. $('span').mouseover(function() { $(this).html('Here is the offer'); });   $(&...

how to open popup window through javascript in code behind( popup window should be aligned center)
I want to use javascript in code behind to open popup window. I have Datalist inside which there is linkbutton. On click of linkbutton open popup window through javascript & that pop up window should be aligned centraly.Regards,Mahesh--------------------click "Mark as Answer" on the post that helps you. Friend, Try this sample . <html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server">    <title>Untitled Page</title>        <style>    .blue{ bac...

Atlas client side control value available to server side C# code behind
I have an existing ASP.NET application. The page contains a datagrid (asp:datagrid). In my current C# code behind, I fetch data from SQL Server 2005 and bind to the datagrid when a button is selected (Click event). There can be many entires in the grid however, so the user typically enters text in a textbox as a filter on the returned results from SQL Server 2005. Now after studying an Atlas sample animalservice http://atlas.asp.net/docs/atlas/doc/data/default.aspx, with an HTML suggestion text box, I would like to use client-side Atlas to give the user a better indication of...

How to open a popup window from C# code behind
Hi, When users click on submit button on my application, first it validates the data using requiredfieldvalidators, and then once all the data is perfect a popup window should open that tells them "please wait, processing request", the window stays as long as the parent unloads, I am able to do it by using Javascript and adding OnClick attribute to the button, but the problem is the popup opens everytime we click the button, even if it it fires the validators and not move to the next page, Can Anyone Help?? How about adding the popup code to the onsubmit event handler of the form tag inst...

How to open a popup window from C# code behind
Hi, When users click on submit button on my application, first it validates the data using requiredfieldvalidators, and then once all the data is perfect a popup window should open that tells them "please wait, processing request", the window stays as long as the parent unloads, I am able to do it by using Javascript and adding OnClick attribute to the button, but the problem is the popup opens everytime we click the button, even if it it fires the validators and not move to the next page, Can Anyone Help?? How about adding the popup code to the onsubmit event handler of the form tag inst...

open a popup window from.net code behind
Hi I am trying to open a new window from a button in my aspx side. This works, but I have to push the button 2 times before it open. Any idea? Public Shared Sub OpenPopUp(ByVal opener As System.Web.UI.WebControls.WebControl, ByVal PagePath As String) Dim clientScript As String 'Building the client script- window.open clientScript = "window.open('" & PagePath & "')" 'register the script to the clientside click event of the opener control opener.Attributes.Add("onClick", clientScript) End Sub Sub Button1_Click(sender As...

executing server side code and client side (javascript) code simultaneously while clicking a button
how to execute server side code and client side (javascript) code simultaneously while clicking a button in asp.net. You can't. When clicking a button: the client-side executes, the page does a PostBack, then the server-side executes.NC... what if i want to update a database and then open a new windows is it possible with Jscript.net?...

Open new window with javascript from code behind file
What do I have to change to get the line in comment working ?Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click   Page.Validate()   If (Page.IsValid) Then      If Textbox1.Text <> "" Then         UpdateButton_Click(Button1, e)      Else         InsertButton_Click(Button1, e)      End If      'Response...

opening new window from code behind using javascript
Hello,I am trying to open new window when i click on a button using javascript Page.ClientScript.RegisterStartupScript(this.GetType(), "openwindow", "window.open('WebForm2.aspx','','height=200,width=300');", true);this is the code i am using.But the problem is it postsback whole page.Can some body tell me how i can open new window without posting back the page.ThanksVinod   Hi Vinod,Do you use a scriptmanager on your page?If so, then you should use the RegisterStartupScript method of the ScriptManager class (= ScriptManager.RegisterStar...

I am using a client side javascript to open a new window and have a problem
I have a user control..On it i have the word 'open' as a link....calling my javascript to open another page.....This page then auto close with javascript...Problem is when you click on 'open' it brings up my page and another page about:blank.......how do you avoid this???? hello, u would like to check my article on the following address: Pop Up Window from inside ASP.NET best of luck.Bilal Hadiar, MCP, MCTS, MCPD, MCTMicrosoft MVP - Telerik MVP...

Using C# code behind to open a new Internet Explorer window
I'm using the Response object to stream pdf document to the browser when a user hits a particular button on a page. This is working correctly, however the pdf opens in the same browser window. How do I open a new (second) browser window and stream the output to this new window? Thanks! You have to use client side code (javascript) to open a new IE window. You can call the javascript after server side code executed.This posting is provided "AS IS" with no warranties, and confers no rights. Hi, first check out this code sample: Open a popup window after a button click After reading you...

Calling a Form Code-Behind function using Javascript from the Client Side
Hi,Is there any way to call a function in the form codebehind from the client side using javascript? If yes, how? How to send parameters?Thanks. Try reading this article.  It is kind of the opposite of what you are trying to do but maybe it will help.http://www.tek-tips.com/viewthread.cfm?qid=1027513&page=1Hope this helps,MattADV Enterpriseswww.adventerprises.net do a view source on the page and you most liekly will see a do post back function. You can call that with JavaScript and it forces the page back. You can send parameters back by placing them inside of hidden form e...

javascript window.open via button click event in code behind
Hello! I'm trying to open a new window on a click event. If I use the attributes.add in the Page_Load, then pop-up window gets hit before an update occurs...hence, the pop-up window is just a little too early. I'm trying this in my button click event, but it's not bringing up the new window: Response.Write("<script language=""javascript"">window.open('UpdateBudgetConfirm.aspx?UBID=" + strSAID + "','','width=500,height=320,left=200,top=200');"")</script>") Thanks! You wanna use Page.Client...

Web resources about - javascript in c# code behind for window.open() - asp.net.client-side

JavaScript Kit- Your comprehensive JavaScript, DHTML, CSS, and Ajax stop
Your comprehensive JavaScript, DHTML, CSS, and Ajax stop

Let's Code: Test-Driven Javascript by James Shore — Kickstarter
James Shore is raising funds for Let's Code: Test-Driven Javascript on Kickstarter! A screencast series focusing on rigorous, professional Javascript ...

Eloquent JavaScript: A Modern Introduction to Programming
... and pragmatics. I loved the tutorial-style game-like program development. This book rekindled my earliest joys of programming. Plus, JavaScript! ...

Lightbox (JavaScript) - Wikipedia, the free encyclopedia
On a Lightbox-enabled page, a user can click an image to have it magnified in a Lightbox window, which resizes itself according to the size of ...

Open Directory - Computers: Programming: Languages: JavaScript: Tools: Obfuscators
about dmoz - help Top : Computers : Programming : Languages : JavaScript : Tools : Obfuscators Tools for obfuscation/compression JavaScript code. ...

Facebook Open-Sources JavaScript Static-Type Checker Flow
The latest software to be open-sourced by Facebook is Flow , a static-type checker for JavaScript . (more…) New Career Opportunities Daily: ...

Under the Hood: The JavaScript SDK - The use of polyfills - Facebook
Facebook Engineering hat eine Notiz mit dem Titel Under the Hood: The JavaScript SDK - The use of polyfills geschrieben. Du kannst den vollständigen ...

Quickstart: Facebook SDK for JavaScript
This quickstart will show you how to setup the SDK, load social plugins, trigger a dialog, and get it to make some basic Graph API calls.

Facebook App Devs Get Javascript
It has been an oft-lamented fact of the Facebook Platform thus far in its life that, in order to use all but the most simple of Javascript functionality–the ...

Badass JavaScript (@badass_js) on Twitter
WebGLWorker is an open source library that allows using WebGL from Web Workers. Great work as always from @kripken . blog.mozilla.org/research/2014/… ...

Resources last updated: 2/11/2016 11:05:04 PM