You must Sign In to post a response.
  • Category: ASP.NET

    Button Click to open two web page in C# web application

    Hi all,
    in asp.net web application ,i need to open two web pages for a single button_click.

    for ex in defalut.aspx page ,button control is there ,another two pages default2.aspx and default3.aspx .
    when the button is cliced in default.aspx two webpage should open ,default2.aspx and default3.aspx simultaneously.

    Can anyone please send me the corect code in C#


    Thanx in advance,
    Kumar
  • #289424
    Hi,

    I have already posted this earlier today.

    Two new pages as per your requirement:
    string lstrCurrentFormattedURL = Request.CurrentExecutionFilePath.Remove(Request.CurrentExecutionFilePath.LastIndexOf("/"), Request.CurrentExecutionFilePath.Length - Request.CurrentExecutionFilePath.LastIndexOf("/")).ToString();
    btnEnter.Attributes.Add("onclick", "window.open('" + lstrCurrentFormattedURL + "/Default2.aspx');window.open('" + lstrCurrentFormattedURL + "/Default3.aspx');");

    Note: Request.CurrentExecutionFilePath will return current URL path including page name. SO i formatted the string to obtain URL without page name and stored it in the variable 'lstrCurrentFormattedURL'.

    Thats it.

    My Previous post as follows:

    For web application call window.open() function two times in single event:

    Sample code using HTML button is as follows:
    <INPUT Type="button" OnClick="window.open('http://www.google.ca');window.open('http://www.google.co.in')" value="enter">

    Sample code using ASP.Net button is as follows:
    <asp:Button runat="Server" ID="btnEnter" Text="Open Two Windows" OnClientClick="window.open('http://www.google.ca');window.open('http://www.google.co.in')"/>

  • #289437
    hi,
    i need to open the two windows in single button click using query string .i need to get the Empid in query string ,and the values should pass through the two windows using single button click.
    i cant able to add query string in the button click event like this

    OnClientClick="window.open('Default.aspx?Empid=" + txtempid.Text)"

    Im getting error message in this .please give me some idea

  • #289445
    Ok

    Use the following:

    string lstrEmpID = txtempid.Text;
    string lstrCurrentFormattedURL = Request.CurrentExecutionFilePath.Remove(Request.CurrentExecutionFilePath.LastIndexOf("/"), Request.CurrentExecutionFilePath.Length - Request.CurrentExecutionFilePath.LastIndexOf("/")).ToString();
    btnEnter.Attributes.Add("onclick", "window.open('" + lstrCurrentFormattedURL + "/Default2.aspx?Empid=" + lstrEmpID +"');window.open('" + lstrCurrentFormattedURL + "/Default3.aspx?Empid=" + lstrEmpID + "');");

  • #289468
    use
    OnClientClick="window.open('Default.aspx?Empid=" + txtempid.Text+"')"

    There had been a syntax error.


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.