Tag: 用户控件

base.OnLoad(e)在ASP.NET页面中

我可能误解了base.OnLoad(e);的含义base.OnLoad(e); 我的理解是这个语句将调用它所调用的类的基类的OnLoad方法。 但是,当我使用调试器逐步执行代码时,我看到不同的结果。 public abstract class BaseUC : System.Web.UI.UserControl { protected override void OnLoad(EventArgs e) { base.OnLoad(e); SomeAbstractMethod(); } } 在ascx.cs具体类中 public partial class MyUserControl : BaseUC { protected void Page_Load(object sender, EventArgs e) { //On Load logic } } 我在base.OnLoad(e)上有一个断点。 当我按F11(步入)时,调试器将我带到MyUserControl的Page_Load ,因此控制流程为: BaseUC.OnLoad() MyUserControl.Page_Load() BaseUC.SomeAbstractMethod() 有人能解释一下这里发生了什么吗?

显示每个usercontrol文本框中的每条记录

我创建一个usercontrol(usercontrol2)并在usercontrol(usercontrol2)上添加textBox。 表格代码: using (SqlConnection myDatabaseConnection = new SqlConnection(myConnectionString.ConnectionString)) { myDatabaseConnection.Open(); using (SqlCommand SqlCommand = new SqlCommand(“Select LastName from Employee”, myDatabaseConnection)) using (SqlDataAdapter da = new SqlDataAdapter(SqlCommand)) { SqlDataReader DR1 = SqlCommand.ExecuteReader(); int y = 0; while (DR1.Read()) { y++; for (int i = 0; i < y; i++) { UserControl2 userconrol = new UserControl2(); userconrol.Location […]

覆盖基类中定义的属性

我有类层次结构是这样的情况, +—————+ | UIElement | |—————| +———————-+ | … | | My Windows Application | SomePropert{} | |———————-| | |<—+ |+——————–+| | | | ||MyUserControl || +—————+ | ||——————–|| +————–+—–+ || || |FrameWorkElement | |+——————–+| |——————–| |//Want to use | | … |<-+ |// SomeProperty; | +——————–+ | | | +———–+-+ | | |Control | […]

缩放用户控件中的裁剪像素

我开发了一个用户控件。 用户控制就像一个放大镜玻璃。 用户控件具有图像按钮,其显示逐像素裁剪的图像。 StorageFile storageFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri(“ms-appx:///Assets/wallpaper.jpg”, UriKind.RelativeOrAbsolute)); using (Windows.Storage.Streams.IRandomAccessStream fileStream = await storageFile.OpenAsync(FileAccessMode.Read)) { BitmapImage bitmapImage = new BitmapImage(); await bitmapImage.SetSourceAsync(fileStream); WriteableBitmap writeableBitmap = new WriteableBitmap(bitmapImage.PixelWidth, bitmapImage.PixelHeight); fileStream.Seek(0); await writeableBitmap.SetSourceAsync(fileStream); writeableBitmap = writeableBitmap.Crop(Convert.ToInt32(xValue), Convert.ToInt32(yValue), 100, 100); MagnifyTip.image1.ImageSource = writeableBitmap; 现在,MagnifyTip.image1具有一个设置为裁剪图像的图像源。 我的要求是缩放裁剪区域,然后将其指定给图像源。 用户控件看起来像这样 帮助将不胜感激

将Form的值传输到Usercontrol

我创建了一个用户控件并向其添加了一个文本框。 在我的Windows窗体中,我添加了我创建的用户控件并添加了一个文本框和一个按钮。 如何将我从Form的文本框输入的文本复制到Usercontrol的文本框,反之亦然。 像usercontrol.textBox1.text = textBox1.text这样的东西

Asp.Net WebForms – 如何将ViewData作为param传递给用户控件

我是ASP.net的新手,并inheritance了一个应用程序进行更新。 虽然遇到了一些我需要帮助理解的情况,但我的情况还算不错。 我有一个用户控件uc:speciesgrid ,它接受一些参数: applicationId和species应该来自ViewData并作为参数传递,但我找不到有效的语法。 对它的硬编码调用(有效)是: 我尝试了<%, <%=, <%#所有组合,并且无效。 所以类似于: <uc:speciesgrid runat="server" ID="speciesgrid1" applicationId='’ species=”Dog”/> 错误都是一样的: {“Cannot create an object of type ‘System.Int32’ from its string representa{ion ‘ViewData[\”NoiId\”]’ for the ‘applicationId’ property.”} 很明显,无论我包含什么,都是按字面解释,而不是让服务器替代值。 我也试过设置一个变量并使用它,但错误是一样的。 正在工作的是访问用户控制器中的ViewData[‘NoiId’] : protected void Page_Load(object sender, EventArgs e) { … Debug.WriteLine(“In the controller, ViewData[‘NoiId’] is: ” + ViewData[“NoiId”]); } > In […]

如何使用字符串可以转换UserControl

有没有什么方法/可能性我可以用UserControl替换字符串? 除了LoadControl并将其添加到另一个控件,如页面或占位符。 原因是用户在页面上添加内容并输入类似{uc:test}的字符串,我想解析此文本并用UserControl替换{uc:test}。 换一种说法 ; 用户输入将是“bla bla bla {uc:test} bla bla”,当我从数据库中检索它时如何注入usercontrol并将其替换为{uc:test} 谢谢。

在WPF中的两个用户控件之间发送命令

我正在尝试从一个UserControl向另一个UserControl发送命令。 第一个包含一个按钮,第二个包含一个派生自Border类的自定义类。 我希望当我单击UserControl的Button以在UserControl中的CustomBorder中执行Redraw method时。 这是我到目前为止所做的。 MainWindow.xaml: 的UserControl1: UserControl2: CustomBorder类: using System.Windows; using System.Windows.Controls; namespace SendCommands { public class CustomBorder : Border { public void Redraw() { // Operations to redraw some elements inside the CustomBorder MessageBox.Show(“We did it!”); } } } ViewModel.cs: namespace SendCommands { class ViewModel { } } 请有人帮助我一劳永逸地学习这个。 我是MVVM概念的新手,我已经阅读了很多但没有结果。 我真的需要一个实用的解决方案才能使概念正确。

等待Winform UserControl加载

我有一个自定义的Winform Infopath UserControl,它从sharepoint库加载一个表单。 打开表单后,我有一系列函数调用,从表单中提取一些数据,甚至是截屏function。 但是表单加载需要花费很多时间,并且其他函数在表单加载之前完成得太快,这给了我错误的结果。 有没有办法我可以有一个等待函数,在调用其他函数之前等待infopath表单完成加载?(在c#中) –update 示例代码: 在UserControl中,我有一个表单初始化函数,它基本上加载表单 public void InitializeInfoPathForm(string myurl) { if (this.IsInitialized) return; CreateForm(new Uri(myurl),null); } public void CreateForm( Uri formUrlName, Stream dataStream) { TestInitialization(); try { this.formControl.Close(); // Open / create a form if (dataStream != null) formControl.Open( formUrlName.ToString() ); else { formControl.Open( formUrlName.ToString()); } RefreshView(UIStatesForm.DocumentReadMode); } catch (Exception) { […]

公开然后使用OnTextChange事件处理程序

相关问题: 在自定义TextBox上添加自定义OnTextChange事件处理程序 在相关问题中,我问我如何在自定义文本框控件中公开OnTextChange,我们通过以下方式解决了这个问题: public event EventHandler TextChanged { add { customTextBox.TextChanged += value; } remove { customTextBox.TextChanged -= value; } } 我正在尝试在实现控件时使用这样的TextChanged事件: 运行时似乎永远不会出现以下情况: protected void CustomTextBox_OnTextChanged(System.EventArgs e) { // Do something here } 或点击: protected void CustomTextBox_OnTextChanged(object sender, EventArgs e) { // Do something here } 我做错了什么,我错过了什么,这是我做这一切的最佳方式或常用做法吗?