开发者

How to share html component amount different page

In ASP.NET, I have a master page, and five other pages which are under master page.

In all five pages, I need to implement a button, after clicking it, will generate different download results.

My original implementation is, in all five page, will all have a "Button", so in code behind will have corresponding event method to generate the download.

But my approach, will have duplicated html compoents.

Is there a way I can define the download button in my master page, when clicking button in different 开发者_如何学编程page, event method from different page will be invoked?


Yes you can, on master page you can have a Download Button and on it click check the URL, which will help you to identify the request has come from which page. Then you can write code on the basis of current page being displayed.


You can use the SHTML instead of HTML and include it every where that you need it.


I don't know what exactly You want to achieve, but maybe it would be better to have one aspx with the button and load the correct ascx file to this page according to some criteria? Each ascx can derive from some interface with some method, f.e. Click(), and each time the button on aspx is clicked, the Click() method from currently loaded ascx can be called.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜