对asp.net中的用户控制有一些疑问请有人清楚吗? [英] Have some doubts about user control in asp.net please anyone can clear that?
问题描述
实际上asp.net中的用户控件是什么?根据我的理解,它的控件如网格,文本框,菜单,标题等由用户创建,可以在n个页面中使用。
i已阅读有关此内容的文章但仍然困惑。
如果我在我的用户控制页面中创建一个按钮,我可以在那里添加该按钮的代码(在ascx.cs中)?
那么我怎么能在其他aspx页面中添加此按钮?在添加按钮后,我需要编写任何代码,否则它将查找我在该按钮的ascx.cs页面中编写的代码?
你是对的,用户控件是您可以通过在其上编写自定义代码来创建和自定义的任何控件,如按钮。
然后您可以使用该用户控件n页中的相同功能。
如何在aspx页面中使用用户控件,检查这些链接< br $> b $ b
使用ASP.NET用户控件创建可重用元素 [ ^ ]
直接创建ASP.NET用户控件lib rary [ ^ ]
读取此内容..
http://msdn.microsoft.com/en-us/library/y6wb1a0e(v = vs.140)的.aspx [<一个href =http://msdn.microsoft.com/en-us/library/y6wb1a0e(v=vs.140).aspx\"target =_ blanktitle =New Window> ^ ]
并查看用户控制的优点..
http://stackoverflow.com/questions/8540679/advantages-and-disadvantages-of-usercontrol-in-asp-net [ ^ ]
http://www.dotnet-guide.com/usercontr ol5.html [ ^ ]
http://stackoverflow.com/questions/3110060 / using-web-user-controls-instead-web-forms [ ^ ]
用户控制事件处理方法
捕获按钮的用户控件点击事件页面 [ ^ ]
用户控制事件处理方法 [ ^ ]
Actually what is a user control in asp net? As per my understanding its a control like grid,textbox,menu,header etc created by user and can use in n number of pages.
i have read article about this but still confused.
If i create a button in my user control page, i can add code for that button there right (in ascx.cs) ?
So how can i add this button in other aspx pages ? And after adding button do i need write any code or it will look for the code which i have written in ascx.cs page for that button?
You are right, User control is any control which you can create and customize by writing your customize code on it, like a button.
and then you can use that user control with the same functionality in n number of pages.
how you can use a user control in your aspx page for that , Check these links
Creating Reusable Elements with ASP.NET User Controls[^]
Straight way to create ASP.NET user controls library[^]
Read This..
http://msdn.microsoft.com/en-us/library/y6wb1a0e(v=vs.140).aspx[^]
And See Advantages of user control..
http://stackoverflow.com/questions/8540679/advantages-and-disadvantages-of-usercontrol-in-asp-net[^]
http://www.dotnet-guide.com/usercontrol5.html[^]
http://stackoverflow.com/questions/3110060/using-web-user-controls-instead-of-web-forms[^]
Approaches for User Control Event Handling
Capture Button’s Click Event of User Control in the Page[^]
Approaches for User Control Event Handling[^]
这篇关于对asp.net中的用户控制有一些疑问请有人清楚吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!