I'm writing my own Modal Popup as a template control in ASP.NET. I got two template containers - one for the heading of the window and one for the actual control i want to display in the modal window (let's call it the form control). The form controls can contain server controls like buttons, textbox'es etc.
我在ASP.NET中编写自己的Modal Popup作为模板控件。我有两个模板容器 - 一个用于窗口标题,另一个用于我希望在模态窗口中显示的实际控件(让我们称之为窗体控件)。表单控件可以包含服务器控件,如按钮,文本框等。
It works well, except when i want to access the form control in my web page. My codebehind won't recognize the content in the template control - just like it won't in, say a Repeater. So i figured a Panel control works just like what i need, except the Panel control only has "one container" and i'd really like to be able to set both a header and the content (form control).
它工作得很好,除非我想访问我的网页中的表单控件。我的代码隐藏不会识别模板控件中的内容 - 就像它不会进入,比如说Repeater。所以我认为Panel控件就像我需要的那样工作,除了Panel控件只有“一个容器”,我真的希望能够设置标题和内容(表单控件)。
I figured i could overwrite the Panel control to add my own html but that would limit my header to be something encodeable in an attribute. So is my best bet really to expose the Heading as just a property, instead of a template and thus being limited in what i can write for heading?
我想我可以覆盖Panel控件来添加我自己的html但这会限制我的标题是属性中可编码的东西。因此,我最好的选择是将标题公开为一个属性,而不是模板,从而限制我可以为标题编写的内容?
2 个解决方案
#1
0
Just as you can with a repeater, try using the ParentControl.FindControl(...) method to get the control you desire.
就像使用转发器一样,尝试使用ParentControl.FindControl(...)方法来获得所需的控件。
#2
0
I ended up overriding the Panel control, accepting that i can only "pass" one set of controls as its children. Also i had to make the heading a property i set as an attribute on the modalpopup control.
我最终覆盖了Panel控件,接受我只能“传递”一组控件作为其子控件。此外,我必须使标题成为我在modalpopup控件上设置为属性的属性。
Even though i couldn't solve it the way i wanted to, i think the solution is good enough.
即使我无法按照我想要的方式解决它,我认为解决方案已经足够好了。
#1
0
Just as you can with a repeater, try using the ParentControl.FindControl(...) method to get the control you desire.
就像使用转发器一样,尝试使用ParentControl.FindControl(...)方法来获得所需的控件。
#2
0
I ended up overriding the Panel control, accepting that i can only "pass" one set of controls as its children. Also i had to make the heading a property i set as an attribute on the modalpopup control.
我最终覆盖了Panel控件,接受我只能“传递”一组控件作为其子控件。此外,我必须使标题成为我在modalpopup控件上设置为属性的属性。
Even though i couldn't solve it the way i wanted to, i think the solution is good enough.
即使我无法按照我想要的方式解决它,我认为解决方案已经足够好了。