ASP.NET:将值从用户控件传递到页面? [英] ASP.NET: Pass value from User Control to page?

查看:27
本文介绍了ASP.NET:将值从用户控件传递到页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 ASP.NET(使用 VB)中创建一个用户控件,该控件使用文本框上的自动完成 ajax 控件来获取值.然后我希望页面根据从该控件传递给它的任何值回发并运行一些代码.问题是,我不确定如何做到这一点.我相信这很容易,我应该知道,但我不知道.

I am creating a user control in ASP.NET (using VB) that uses the autocomplete ajax control on a textbox to get a value. Then I want the page to post back and run some code according to whatever value is passed to it from this control. Problem is, I'm not exactly sure how to do this. I'm sure it's easy and I should know, but I don't.

提前致谢!

推荐答案

在您的用户控件中为值公开一个属性

In your user control expose a property for the value

Public Property SomeValue() As String
Get
    Return textbox1.Text
End Get
End Property

然后在您的 aspx 页面加载中,只需引用用户控件的值.

Then in your aspx page load, just reference the user control's value.

userControl1.SomeValue

编辑,我只是​​尝试将语法更改为 vb.net,我实际上并不了解 vb,因此该语法可能正确也可能不正确.

Edit, I just tried changing my syntax to vb.net, I don't actually know vb, so that syntax may or may not be right.

这篇关于ASP.NET:将值从用户控件传递到页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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