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.

0
jewelhere
1/25/2009 6:01:14 AM
asp.net.web-forms 93655 articles. 3 followers. Follow

6 Replies
3469 Views

Similar Articles

[PageSpeed] 10

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_maharaja

Please mark as answer if you got expected solution.
-1
santosh_maharaja
1/25/2009 2:29:10 PM

http://plugins.jquery.com/project/confirm  Cool stuff

// The action. $('span').mouseover(function() { $(this).html('Here is the offer'); });   $('span').confirm({ msg:'See my interesting offer?', stopAfter:'ok', eventType:'mouseover', timeout:3000, buttons: { ok:'Sure', cancel:'No thanks', separator:' ' } });

popups are disabled on lots of browsers but you can still use them.  modify the code a little.


 


Good Luck



-1
Danny117
1/25/2009 4:38:20 PM
In this example the popup page ust be in the same folder as the calling page.

 

    protected void Page_Load(object sender, EventArgs e)
    {
        btnPopup2.Attributes.Add("onclick", "if(confirm('Open Popup?')) window.open('Popup.aspx');");
    }
  
-1
rickcimbalo
1/25/2009 7:27:47 PM

thanks to all.

nothing working here.

here's my code:

ClientScript.RegisterStartupScript(this.Page.GetType(), "Report", "if(window.confirm('Do you want to see report?')){window.fnOpenReport='Reports/BuyerReportViewer.aspx?BuyerNo=" + BuyerNo + "';}else{window.location.href='BuyerEntry.aspx';}", true);

 here a window open but not pop up.

i just want to open popup window.please help

1
jewelhere
1/26/2009 5:51:16 AM

 Most browsers won't allow a popup to open unless it's a result of a user action, like a button click. You are opening another window in the startup event of a window, this is similar to pop up ads that most users/browsers block.

Either of the AddAttribute posts should work. Maybe you could post the code you used that failed.

1
rickcimbalo
1/26/2009 1:17:37 PM

 Another possiblity is that your button is on a dynamic control (like a FormView). In that case you should put the AddAttribute code in the Page_PreRender event of the page (instead of the Page_Load event) or in the _DataBound event of the control (if it has one).

-1
rickcimbalo
1/26/2009 3:32:57 PM
Reply:

Similar Artilces:

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

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

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

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

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

Confirmation Message Box using Javascript in between code from Code behind
Hi all, Im using C# as my code behind, im having a code in the button click event where im checking whether a file is exists, if it exists then it show the confirmation message box like "file found, want to continue", but its happening if we register the script in the page load  and its not checking the condition. By clciking the button itself its showing the message box.   i need that script should get pop up only after the condition get satisfied. Is it possible? Please help me out to solve this problem. Thanks a lot in advance. The code is given below private void Page...

superreview granted: [Bug 263844] Javascript window.close() on popup not working when popup is opened in tab : [Attachment 162257] set opener on opened windows diverted into tabs
Boris Zbarsky <bzbarsky@mit.edu> has granted Boris Zbarsky <bzbarsky@mit.edu>'s request for superreview: Bug 263844: Javascript window.close() on popup not working when popup is opened in tab https://bugzilla.mozilla.org/show_bug.cgi?id=263844 Attachment 162257: set opener on opened windows diverted into tabs https://bugzilla.mozilla.org/attachment.cgi?id=162257&action=edit ------- Additional Comments from Boris Zbarsky <bzbarsky@mit.edu> r+sr=bzbarsky. Dan, thanks for doing this! I really wish we could factor some of this code that's being copied f...

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

validate web form entries via textbox again in the C# (code-behind) code again
I have requiredfieldvalidators, comparevalidators and a regualarexpressionvalidator for the email on my login form for the textboxes. My question is do I have to check in the C# to make sure the textboxes have values and if so what does a experienced programmer think of my code. What would you change??? Are the if statements the way to go??? Thanks for making me a better coder................newbieprotected void LoginButton_Click(object sender, EventArgs e){string emailAddress = String.Empty;string password = String.Empty;if (!String.IsNullOrEmpty(TextBoxEmailAddress.Text)){emailAddress = Te...

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

open popup window with click on image and datalist in popup window
 I have a picture,i want to when i click on it a popup window open,in that pop up window i want to have a data list that in every field of it be a link and a picture,when user click on a link with a url go to another website in that pop up window,how can I do this senario? Where are you having a problem? We can't build the thing for you. Post the code that you have so far. NC...    I want when I click on a picture a popup window open Like this? <img src="yourImageFile.jpg" onclick="window.open('Page2.aspx');" /> See http://www.ja...

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

Web resources about - Javascript confirm message in c# code behind,by clicking ok popup window open - asp.net.web-forms

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: 1/19/2016 8:48:03 PM