473,407 Members | 2,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

popup on Button Click and running server-side button_Click() code?

VMI
I have a LinkButton_search on my Page1.aspx that opens up a popup page called
popup.aspx. I do this with LinkButton.Attributes.Add() on the Page_Load of
Page1.aspx.
How can I add server-side code to LinkButton_search_Click() so that the code
in there runs before opening the popup window? The problem is that I fill a
Session variable when I click on the button that will then be used in the
Page_Load of my Popup window. So basically this is what I want:
1) Add the "onclick" Attribute to the LinkButton (so it's a popup window)
2) Run the LinkButton_search_Click(object sender, EventArgs e) to fill the
Session variable
3) Open popup.aspx as a popup window and in its Page_Load() use the Session
variable that was filled in step 2.

Any help is appreciated.
Thanks
Oct 9 '06 #1
2 3560
What you can do is -

Write your Server side script on the clicked event. Also, build your
javascript function in a string variable and then use the
RegisterClientScript functionality to register and run the client script. You
can google for RegisterClientScript and you should be able to get some
examples for that.
--
Ameet Phadnis
Sr. Technical Consultant
e Tek Global Inc.
ASP Alliance Author Page: http://aspalliance.com/author.aspx?uId=44260
"VMI" wrote:
I have a LinkButton_search on my Page1.aspx that opens up a popup page called
popup.aspx. I do this with LinkButton.Attributes.Add() on the Page_Load of
Page1.aspx.
How can I add server-side code to LinkButton_search_Click() so that the code
in there runs before opening the popup window? The problem is that I fill a
Session variable when I click on the button that will then be used in the
Page_Load of my Popup window. So basically this is what I want:
1) Add the "onclick" Attribute to the LinkButton (so it's a popup window)
2) Run the LinkButton_search_Click(object sender, EventArgs e) to fill the
Session variable
3) Open popup.aspx as a popup window and in its Page_Load() use the Session
variable that was filled in step 2.

Any help is appreciated.
Thanks
Oct 9 '06 #2
Howdy,

Quick example:

-- BEGIN SEARCH PAGE --

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:LinkButton runat="server" ID="SearchButton" Text="Search"
OnClick="SearchButton_Click"/>
</div>
</form>
</body>
</html>

//code behind

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class SearchPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void SearchButton_Click(object sender, EventArgs e)
{
DateTime date = DateTime.Now;
Session["SearchVariable"] = date;

Response.Write(date);

RegisterPopupScript();
}

/// <summary>
///
/// </summary>
private void RegisterPopupScript()
{
Type type = this.GetType();

if (ClientScript.IsStartupScriptRegistered(type, "PopupScript"))
return;

System.Text.StringBuilder script = new System.Text.StringBuilder();

script.Append("<script language=\"javascript\"
type=\"text/javascript\">\n");
script.Append("//<!--\n");
script.Append("window.open('popup.aspx', '_blank',
'width=400,height=400');");
script.Append("//-->\n");
script.Append("</script>");

ClientScript.RegisterStartupScript(type, "PopupScript", script.ToString());

}
}
-- END SEARCH PAGE --

-- BEGIN POPUP PAGE --

// place label with ID="SearchResult"
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class popup : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
SearchResult.Text = Convert.ToString(Session["SearchVariable"]);
}
}
-- END POPUP PAGE --

--

Hope this helps

Milosz Skalecki
MCP, MCAD
"VMI" wrote:
I have a LinkButton_search on my Page1.aspx that opens up a popup page called
popup.aspx. I do this with LinkButton.Attributes.Add() on the Page_Load of
Page1.aspx.
How can I add server-side code to LinkButton_search_Click() so that the code
in there runs before opening the popup window? The problem is that I fill a
Session variable when I click on the button that will then be used in the
Page_Load of my Popup window. So basically this is what I want:
1) Add the "onclick" Attribute to the LinkButton (so it's a popup window)
2) Run the LinkButton_search_Click(object sender, EventArgs e) to fill the
Session variable
3) Open popup.aspx as a popup window and in its Page_Load() use the Session
variable that was filled in step 2.

Any help is appreciated.
Thanks
Oct 9 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: dibyendu_k | last post by:
Hi, There is a problem i cant solve regarding Internet Explorer 5.5. It is regarding the Print Dialog Box. From a webpage if I open a popup window (window.open()) containing buttons Print and...
6
by: mkobus | last post by:
Im relatively new, so please be patient with me... I need to update a parent .aspx screen from a popup and close the popup. Normally I would use...
1
by: Joseph Yang | last post by:
Hello all, I have a datagrid bounded with an Arraylist containing contact objects, and a edit button (<asp:imagebutton/>) in each row When I click edit button, I want a window popup so I can...
4
by: SteveS | last post by:
Hello. This is a strange problem which does not make sense to me. I open a popup page with the following javascript code: function OpenDenyWindow(changeId) {...
1
by: Earl Teigrob | last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at...
1
by: dapkniht | last post by:
Hello, Here's my situation... I have an ASP.NET 2.0 (C#) page with a link button. When a user clicks the button I need it to execute the code behind code for the link button on click event. At...
2
by: Del | last post by:
I have a popup form that consist of a single field called EnteredBy and a Subform that has three fields. The popup form also has a button in the Form Footer called close. In the On Click event I...
2
by: wreed06 | last post by:
Hello, I have 2 problems. In my webpage, I have a dropdown list with a button that takes the user to a popup window specific to the option. I am using Firefox 2.0.0.13. I have successfully...
5
by: wreed06 | last post by:
I have 2 problems. In my webpage, I have a dropdown list with a button that takes the user to a popup window specific to the option. I am using Firefox 2.0.0.13. I have successfully validated my HTML...
5
econVictim
by: econVictim | last post by:
hey guys, i'm new to working with .net c#. I've been doing some more advanced things without knowing much about what i'm doing... I need to create this popup window without using the javascript.....
0
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.