母版页和方法 [英] Master Pages and methods

查看:64
本文介绍了母版页和方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我有一个带有ImageButton和Click事件的母版页。

然后,我创建了一些页面在这个母版页上。

我需要根据页面改变Click事件的动作。


例如:如果我的页面(基于Master Page)是一个客户注册,我需要在ImageButton点击事件中调用''RegisterCustomer()''方法。如果是带有员工注册的
a页面,我需要ImageButton点击事件

调用''RegisterEmployee()''方法。


我已经尝试覆盖页面中的ImageButton Click事件,但是

失败了。


我该怎么办?


谢谢。

Hello,

I have a Master Page with a ImageButton and a Click event associated with.
Then, I''ve created some pages based on this Master Page.
I need to change the action of Click event will perform depending of the page.

For example: If my page (based on the Master Page) is a customer register, I
need that the ImageButton click event call ''RegisterCustomer()'' method. If is
a page with an employee register, I need that the ImageButton click event
call ''RegisterEmployee()'' method.

I''ve tried override the ImageButton Click event in the page, but
unsuccessfully.

How can I do it?

Thank you.

推荐答案

" Bruno Sampaio" < Br ********** @ discussion.microsoft.com写信息

新闻:0F ****************** **************** @ microsof t.com ...
"Bruno Sampaio" <Br**********@discussions.microsoft.comwrote in message
news:0F**********************************@microsof t.com...

我该怎么办?
How can I do it?



听起来你需要重新考虑一下你的架构...


MasterPages本质上是一种方式为您的网站提供统一的外观和感觉,并提供大多数(如果不是全部的话)
内容页面的常用功能。如果每个内容页面都需要以某种方式修改主页面的功能,而不是更改Header.Title

属性,那么您可能会质疑MasterPages是否是
实现你网站的最佳方式。


当然,如果每个内容页面都需要一个执行动作的按钮

unique到那个页面,然后将按钮移出MasterPage进入每个内容页面


Sounds like you need to re-think your architecture a bit...

MasterPages are, essentially, a way to provide a uniform look and feel for
your site, and to provide any functionality common to most if not all
content pages. If every content page needs to modify the functionality of
the MasterPage in some way rather than, say, changing the Header.Title
property, then you might question whether MasterPages are the best way to
implement your site.

Certainly, if each content page needs a button which performs an action
unique to that page, then move the button out of the MasterPage and into
each content page.


好!我理解你,但是一个问题。


这个按钮应该存在于所有页面中,而按钮是一个UI组件,

那么,MasterPage是最好的放置按钮的地方。

问题是:每个页面需要一个不同的按钮动作。


最好把按钮放在页面中吗?如果我需要,例如,更改ImageButton的

ImageUrl属性?如果按钮在一个地方,我将需要

仅在一个地方更换。


Mark Rae写道:
Ok! I understand you, but a question.

This button should exist in all pages and the button is a UI component,
then, the MasterPage is the best place to put the button.
The problem is: each page needs a different button''s action.

Is better put the button in the page? If I need, for example, change the
ImageUrl property of ImageButton? If the button is in one place, I will need
to change in one place only.

"Mark Rae" wrote:

" Bruno Sampaio" < Br ********** @ discussion.microsoft.com写信息

新闻:0F ****************** **************** @ microsof t.com ...
"Bruno Sampaio" <Br**********@discussions.microsoft.comwrote in message
news:0F**********************************@microsof t.com...

我该怎么办?
How can I do it?



听起来你需要重新思考一下你的架构...


MasterPages本质上是一种方式为您的网站提供统一的外观和感觉,并提供大多数(如果不是全部的话)
内容页面的常用功能。如果每个内容页面都需要以某种方式修改主页面的功能,而不是更改Header.Title

属性,那么您可能会质疑MasterPages是否是
实现你网站的最佳方式。


当然,如果每个内容页面都需要一个执行动作的按钮

unique到该页面,然后将按钮移出MasterPage并进入每个内容页面



Sounds like you need to re-think your architecture a bit...

MasterPages are, essentially, a way to provide a uniform look and feel for
your site, and to provide any functionality common to most if not all
content pages. If every content page needs to modify the functionality of
the MasterPage in some way rather than, say, changing the Header.Title
property, then you might question whether MasterPages are the best way to
implement your site.

Certainly, if each content page needs a button which performs an action
unique to that page, then move the button out of the MasterPage and into
each content page.


" Bruno Sampaio" < Br ********** @ discussion.microsoft.com写信息

news:18 ****************** **************** @ microsof t.com ...
"Bruno Sampaio" <Br**********@discussions.microsoft.comwrote in message
news:18**********************************@microsof t.com...

此按钮应存在于所有页面和按钮中是一个UI组件,

然后,MasterPage是放置按钮的最佳位置。
This button should exist in all pages and the button is a UI component,
then, the MasterPage is the best place to put the button.



不,它不是 - 每个内容页面中最好的位置。

No it isn''t - the best place is in each content page.


问题是:每个页面都需要一个不同的按钮动作。
The problem is: each page needs a different button''s action.



这就是每个内容页面中最佳位置的原因。

That''s why the best place is in each content page.


最好放在页面中的按钮?
Is better put the button in the page?



在内容页面中,是......

In the content page, yes...


如果我需要,例如,更改ImageButton的ImageUrl属性?
If I need, for example, change the ImageUrl property of ImageButton?



所以...?

So...?


如果按钮在一个地方,我需要更改只在一个地方。
If the button is in one place, I will need to change in one place only.



Visual Studio.NET中有一个查找和替换功能......

There is a Find and Replace feature in Visual Studio.NET...


这篇关于母版页和方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆