open popup window from code behind

hi

i am coding with vb , i need to open pop up window with out display any tool bars. and also need to pass a value to opening page which will need to get related data to display on pop up.

need to cal java script inside a vb method

 

-1
patfat
1/9/2008 12:33:40 PM
asp.net.web-forms 93655 articles. 3 followers. Follow

10 Replies
2948 Views

Similar Articles

[PageSpeed] 14

You can call this either via javascript or use Ajax

Here is a good example

http://www.codeproject.com/KB/custom-controls/asppopup.aspx 

or the JavaScript version, which uses the the ScriptManager for the JavaScript:

C#

public static void OpenWindow(Page currentPage, String window, String htmlPage, Int32 width, Int32 height)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("popWin=window.open('");
            sb.Append(htmlPage);
            sb.Append("','");
            sb.Append(window);
            sb.Append("','width=");
            sb.Append(width);
            sb.Append(",height=");
            sb.Append(height);
            sb.Append(",toolbar=no,location=no, directories=no,status=no,menubar=no,scrollbars=no,resizable=no");
            sb.Append("');");
            sb.Append("popWin.focus();");

            ScriptManager.RegisterClientScriptBlock(currentPage, typeof(ArvalPage), "OpenWindow", sb.ToString(), true);
        }

 VB

Public Shared Sub OpenWindow(ByVal currentPage As Page, ByVal window As String, ByVal htmlPage As String, ByVal width As Int32, ByVal height As Int32) 
    Dim sb As New System.Text.StringBuilder() 
    sb.Append("popWin=window.open('") 
    sb.Append(htmlPage) 
    sb.Append("','") 
    sb.Append(window) 
    sb.Append("','width=") 
    sb.Append(width) 
    sb.Append(",height=") 
    sb.Append(height) 
    sb.Append(",toolbar=no,location=no, directories=no,status=no,menubar=no,scrollbars=no,resizable=no") 
    sb.Append("');") 
    sb.Append("popWin.focus();") 
    
    ScriptManager.RegisterClientScriptBlock(currentPage, GetType(ArvalPage), "OpenWindow", sb.ToString(), True) 
End Sub 
 
Regards

<<<Bryan Avery>>>


Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue.
-1
Coppermill
1/9/2008 1:22:09 PM

 check out this link > Open a popup window after a button click - ASP.NET Forums

and 

Using the window.open method

you can pass value in QueryString ...

window.open ("Default2.aspx?MyData=DataValue", "mywindow","location=1,status=0,toolbar=0,scrollbars=1,width=100,height=100");

 

hope it helps./. 



Thanx,
[KaushaL] || BloG || Profile || Microsoft MVP

"I would love to change the world, but they won’t give me the source code"


Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and mark your thread as Resolved for the sake of Future Readers.
-1
kaushalparik27
1/9/2008 1:24:02 PM

hi Bryan

I have problem with ScriptManager it says ScriptManager ,ArvalPage not declared

what should i do?

-1
patfat
1/9/2008 3:12:26 PM

in the form_load put this

 btn.Attributes.Add("onclick", "window.open('itemsinfo.aspx','','location=0,resizable=0,ScrollBars=1,statusbar=1,width=980,height=800,left=20,top=10,moveable=0') ;return false")
               


Amjad Ahmad
1
amjad905
1/9/2008 3:21:14 PM

Woops sorry, that what copy and paste does for you, you just need to make sure the second parameter is the Class you are in, if it is on the page it should be GetType(Page)

ScriptManager.RegisterClientScriptBlock(currentPage, GetType(Page), "OpenWindow", sb.ToString(), True
 

Hope that fixes your problem


Regards

<<<Bryan Avery>>>


Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue.
1
Coppermill
1/9/2008 3:26:33 PM

for scriptManager do I need to import any thing

 

1
patfat
1/9/2008 3:33:59 PM

Just need to make sure you have an Ajax enabled website, click on the Ajax Link at the top of the page if you not done this before


Regards

<<<Bryan Avery>>>


Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue.
-1
Coppermill
1/9/2008 3:49:59 PM

 Hi Coppermill,

Coppermill:
ScriptManager.RegisterClientScriptBlock(currentPage, GetType(Page), "OpenWindow", sb.ToString(), True
 

I think there is something wrong with this line, which should be

ScriptManager.RegisterClientScriptBlock(currentPage,currentPage.GetType (), "OpenWindow", sb.ToString(), true);

Regards,

Ivan.

 

1
Ivan
1/11/2008 7:51:09 AM
Well I havent select AJAX  need to try that too. In my code after call java script exit from that function and go back to next lines of button click , there i call 

Response.Redirect(pbUrl) . I think because of that client script not working.

Public Sub Button_Click(ByVal sender As Object, ByVal e As System.EventArgs)

........ 

pbUrl = ProcessChange(strso,process)     ' inside this method i have writen that client script which is not working when response redirect there. if not it works and popup window

....

Response.Redirect(pbUrl)

End Sub

-1
patfat
1/11/2008 10:12:04 AM

Yes you are right


Regards

<<<Bryan Avery>>>


Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue.
-1
Coppermill
1/11/2008 10:39:00 AM
Reply:

Similar Artilces:

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...

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...

how to change these windows form code to web form code?
hi, i'm a beginner of c#,i want to know how to change these windows form code to web form code //////////// private void buttonSign_Click( object sender, System.EventArgs e) { //get original message as byte array byte[] messagebytes = Encoding.UTF8.GetBytes( textOriginalMessage.Text); //create digest of original message using SHA1 SHA1 sha1 = new SHA1CryptoServiceProvider(); byte[] hashbytes = sha1.ComputeHash(messagebytes); //display hash bytes in hex format StringBuilder sb = new StringBuilder(); for (...

Web Forms Designer error
Hi, The web forms designer keeps adding things in a generated InitializeComponent() method. I believe these things shouldn't be there because I've made a new webform with the same code that doesn't add the same stuff. Is there anyway I can see the Web Designer code? Thanks. Just expand out the hidden #region. It is labeled Web Form Designer CodeStarting with ASP.NET 2.0? Look at:Programming Microsoft Web Forms My Blog...

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...

Want to open a popup window from code behind
Hi,I want to open a Popup window with code behind in ASPX page. So if you have ant codes and suggestion please do mail me.I am online on yahoo messsanger in invisible mode and my yahoo chat is is 'naveen_uicsa'ThanxNaveen Hello, use registerstartupscript function .Dim mystr as new StringBuilderwith mystr  .append("<script language='javascript'>")  .append("window.open(theUrl, '', 'toolbar=0,width=350,height=250,left=40,top=50');")  .append("</script>")end withregisterStartupScript("PopupScript", mystr.ToString)Hope this would help.Regards,ForzaOracle, mySQL &...

opening multiple popup windows from code behind
HII am trying to open multiple pop up windows from code behind for the purpose of showing xls files but in only seems to work with one window. this is the code that I have so far. it works fine but when I'm trying to pop up more than one browser it only shows the first one.  file_array = dir.GetFiles("*.xls") For Each file In file_arrayClientScript.RegisterStartupScript (Me.GetType, "popup & file.Name &", "window.open('" & path & "','blank','menubar=no')", True) Next Can somebody help me in th...

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 popup window on click of button event from code behind side
 Hi friends I have one button called Preview which is placed in upadate panel. Now I want to open popup window on click of that button. I can call javascript onclientclick event but before open popup window i want to get some values from current window.I dont want to pass that value in query string. Here is my code <pre> ClientScript.RegisterStartupScript(this.GetType(), "JS", "javascript:window.open('PreviewPop.aspx?DesignID=" + txtImageHide.Value + "','MyTitle','height=250,width=505, top=100, left=100, scrollbars=yes, res...

windows forms in vb .net into web forms
we are creating a database driven website as part of our project. currently we have forms connecting to the database created in visual basic. these windows forms we need to convert into web forms which are asp .net compatible. can u give me an answer or show me a way. Hi, because of the difference in nature between web and win applications you'll need to reimplement at least the UI part. If you have a multitiered application in which the busines logic and data access are in different parts/assemblies you can reuse them. Grz, Kris.Read my blog. Handy Firefox plugins for web developers.Wor...

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 send value form popup window to opener window ??
I have problem and I need everybody help me. I desgning a website using ASP.NET and VB.NET - I want, when user click button as show popup window with list user of system (from database) and click user of list, it's in textbox of opener window. Can you help me code it ??? Thanks a lot !!!  Không học không biết, học rồi sẽ biết  You have to access the window.opener.document object in JavaScript. This will give you access to the DOM. function getOpenerElem(Jb) { return window.opener.document.getElementById(Jb); }  I use this function to access the opening window...

how to open a web page in form of a popup web page
Hello, I have two web pages, let say. Page A : With a Button on it. PAge B: with some info. Now I need to: When I click on the Button of page A.Page B must open in a pop up window.  I can do this but problem is this when I clicked on the button for first time it does not show me any thing and when I clicked on the button for second time then It shows me Page B .My code is as follow:  1 protected void Page_Load(object sender, EventArgs e) 2 { 3 if (!this.Page.IsPostBack) 4 { 5 6 } 7 else 8...

How to know in the code behind if the window has been open from another window
 HiI want to know in the code behind (server side) if the page has been open from another window. In the client side I can check, in a javascript function, if the window.opener is null or not, but how can I know this in the code behind. Is it possible?Thanks,Luis Miguel   I think your best bet might be to use a HiddenField, and populate that HiddenField with the javascript window.opener value. For example: <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html P...

Web resources about - open popup window from code behind - asp.net.web-forms

Window - Wikipedia, the free encyclopedia
This article is about the part of a building. For the Microsoft operating system, see Microsoft Windows . For other uses, see Window (disambiguation) ...

Microsoft Windows Information, Solutions, Tools - Windows IT Pro
Microsoft Windows information and solutions for IT pros. Topics include cloud computing, Windows Server, Exchange, Outlook, PowerShell, virtualization, ...

The Windows Blog
The Windows Blog is Microsoft's Official Blog for the Windows Operating System.

Santa brought you a Windows 10 PC or tablet? Here’s what to do first
If you were fortunate enough to unwrap a new Windows device this Christmas the chances are it will be running Windows 10 . The new operating ...

Virgin Mary image seen on Ga. church window
Rainbow-hued coating on window pane inspires Catholic priest to post on FaceBook

Coming up for Windows 10: Needed upgrades, forced updates
Windows 10 was the biggest news story out of Microsoft in 2015, and looking forward to the coming year, it’s slated to continue as one of the ...

iOS concept brings joy of Windows to iPad
iOS 9 finally brought split-screen views to the iPad, but it’s still not nearly as useful as the windowed multitasking views you get on a Mac. ...

I Can See An Empty Bank Account From My Window
Not mine, for once. With oil prices down along with oil production, the state is facing an Alaska-size shortfall: Two-thirds of the revenue ...

Chelsea still need a 'couple of players' in transfer window - ESPN FC
Chelsea manager Jose Mourinho has targeted two marquee signings to turn his champions into a dream team.

Microsoft Welcomes WordPress Content in Windows App Studio Update
A new update focuses on helping budding developers import WordPress content, add visual polish to their apps and generate ad revenue.

Resources last updated: 12/30/2015 12:18:49 PM