且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

asp.net传递字符串变量到用户控件

更新时间:2023-12-06 10:49:58

使用<%= 是一样的使用的Response.Write(字符串)。这发生在生命周期的,当你ShowPdf控制正在建造和属性初始化比不同点 - 晚得多。尝试,而不是使用<%#,其中规定的DataBind过程中的价值。您可能需要的CreateChildControls或者路径2 被赋予一种价值其他一些方法来调用DataBind你的页面。

Using <%= is the same as using Response.Write(string). This happens at a different point in the lifecycle than when your ShowPdf control is being built and properties being initialized - much later. Try instead using <%#, which sets the value during DataBind. You may need to call DataBind on your Page in CreateChildControls or some other method where path2 is being given a value.