如何将查询字符串传递给用户控件

如何将查询字符串传递给用户控件

本文介绍了如何将查询字符串传递给用户控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在尝试开发用户控件.

在其中,我正在使用AjaxModalPopextender.

我想显示该用户控件中的值列表.

但是我想对大多数表单使用此控件,所以我正在创建一个动态用户控件.

因此,任何人都可以建议如何通过使用querystring或任何其他方式将参数传递给用户控件.


预先感谢

Hi,

I sm trying to develop a user control.

In which ,i am using AjaxModalPopextender.

I want to show list of values in that User Control.

But I want to use this control for most of the forms so i am creating a dynmaic user control.

So can anybody suggest how to pass parameters to user control by using querystring or in any other way.


Thanks in advance

推荐答案

public partial class PopupControl : System.Web.UI.UserControl
{
   public string DisplayValues { get; set; }
}


因此,现在当您使用此控件时,您可以执行以下操作:


So, now when you are using this control, you can do something like:

<uc:popupcontrol  runat="server" id="popup1" displayvalues="some values" xmlns:uc="#unknown" />


同样,如果您正在动态创建这些控件(如您在问题中所述):


Similarly, if you are dynamically creating these controls (as you say in your question):

PopupControl popup = LoadControl(src);
popup.DisplayValues = "some values";


本文相当详细地对此进行了解释-动态加载ASP.NET用户控件 [ ^ ]

当然,也可以像在aspx页面中一样在用户控件中访问任何查询字符串,但是更干净的方法是使用用户控件属性.

希望这会有所帮助!


This article pretty much explains this in detail - Dynamic Loading of ASP.NET User Controls[^]

Of course any query string can also be accessed in a user control just like in a aspx page, but the cleaner way of doing this is with user control properties.

Hope this helps!


这篇关于如何将查询字符串传递给用户控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 21:44