473,386 Members | 1,766 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,386 software developers and data experts.

button click event on master page

oh it hurts to be a newbie again....:-(

I have a button click event I want to handle for a button to create an excel
spreadsheet from gridview contents.
I can't write the code for the button click event on the master cuz it
doesn't know anything about Gridview1.

But if I put the code on the page where GridView1 is and NOT on the
masterpage, then I get this;
Error 1 'ASP.masterpage_master' does not contain a definition for
'Button1_Click' \test_report\MasterPage.master 38

But the tutorials made this all look so easy !!

Thanks,
-Greg
Apr 21 '06 #1
1 5109
public partial class MasterPage : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
if (Page.PreviousPage != null)
{
GridView SourceGridView =
(GridView)Page.PreviousPage.FindControl("GridView1 ");
if (SourceGridView != null)
{
//what do I do here; I need to call a button click event
on the page GridView1 is on as per below. ???????
}
}
}

protected void BtnExport_Click(object sender, EventArgs e)
{
Response.Clear();
Response.AddHeader("content-disposition",
"attachment;filename=FileName.xls");
Response.Charset = "";
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
GridView1.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
}
btnExport code courtesy of Mohammad Azam at http://aspalliance.com/771
Apr 21 '06 #2

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

Similar topics

4
by: Mark Olbert | last post by:
I have a website (ASPNET2) where the master page has a button in it and my login page, which is a detail page of the master page, also has a button (a login button). Everything works fine if I...
4
by: sowencheung | last post by:
Hi, all The scenario is like this: I have a master page, contains two user controls, one is a search control, another is a login control. The server-side <form> is in the master page,...
4
by: bbawa1 | last post by:
I have a button( btnLogOut)in my master page. In page_load event of this master page I want to verify if the button is clicked or not. How can I do that. Thanks in advance. seema
3
by: Jay | last post by:
I am on the 2.0 framework and have run the c:\windows\microsoft.net \framework\v1.1.4322\aspnet_regiis.exe -c and had no success. About half of the buttons on my webforms are firing and the other...
0
by: Valli | last post by:
Hi, I am having a master page & a content page in my project. My content page contains button click event codings.(default.aspx.vb) But the button click event is not getting fired when I click...
9
by: Jonathan Wood | last post by:
Does anyone know of any reason a button on a master page would have no effect? I have a complex HTML page that I'm converting to ASP.NET, and acknowledge I could have something odd that is...
1
by: aawhan | last post by:
I have a master page and a content page in my web page(.net 2008).In the master page i am having some menus.Now after doing some operation in the page if i will click to any other menu then it should...
1
by: aawhan | last post by:
I have a master page and a content page in my web page(.net 2008).In the master page i am having some menus.Now after doing some operation in the page if i will click to any other menu then it should...
1
by: =?Utf-8?B?QXNhZg==?= | last post by:
Hello, I have a Default.aspx page with several controls in a Master Page. When pressing on a Button control Page_Load event is fired on the Default.aspx page and after that the Page_Load event...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.