English 中文(简体)
从用户控制向网页发送数据的最佳方式是什么?
原标题:What s the best way to send data from user control to the page?

我有一页(A)和用户控制,我谨寄送一套数据,如:

姓名

1 aa.pdf

2 bb.doc

3 cc.xls


从用户控制到我的网页

这样做些事情的最有效方式是什么?

最佳回答

在你想要通过的数据类型上,在<代码>User Control上创造财产,并在你创建控制权的网页上居住。

public String ControlProperty
{
    get
    {
        return Convert.ToString(ViewState["ControlValue"]);
    }
}
问题回答

这样做有很多方法。 通常,法典在普通的ASCX控制中是空洞的,而控制则仅仅被拖到网页上。 间接将数据输入网页:

其中一些最常见的情况是使用。 NET gridview, datagrid, or datalist. a. 向电网本身发送数据集或数据。 这并不涉及许多工作,你可以效仿以下几个例子::http://www.c-sharpMM.com/UploadFile/mahesh/DataBledInDataGridMCB112022005207AM/DataBledInDataDataGridMC1/

另一项涉及更多工作的方法是要求网络服务,该服务将含有浏览量清单的json物体重新定位,由客户旁打,并制作一个超文本表格。

这个问题更是你的设想是什么,是你的最佳和最合适的方法。

这简便,使你的数据成为假肢,然后将假肢解到网页上。

var myData = new Dictionary<int, String>();
myData[0]="aa.pdf";
context.Item["Data"] = myData;

//in your page.
var myData = (Dictionary<int, String>)(context.Item["Data"]);

以上代码只是原型草案,你可以在你的环境中尝试。

Sean





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签