c# - Overriding VerifyRenderingInServerForm on dynamically created Pages() -
i having problems regarding creation of page dynamically :
p = new page(); page mypage = new page(); formatt ctrl = (formatt)mypage.loadcontrol("path/to/my/file.ascx"); // here lies gridview of evil mypage.controls.add(ctrl);
problem receive
control ... must placed within form tag runat=server
ok, i've found out need override verifyrenderinginserverform
method able phone call formless page, how can override verifyrenderinginserverform
since don't have aspx file.
ps: have related question , don't know do, since different questions solution goes same problema , , gave on lastly solution - see : form null in dynamically created pages
you can seek utilize custom class overrides verifyrenderinginserverform
:
public partial class mycustompage : system.web.ui.page { public override void verifyrenderinginserverform(control control) { } protected void page_load(object sender, eventargs e) { var p = new mycustompage(); formatt uc = (formatt)p.loadcontrol("path/to/my/file.ascx"); p.controls.add(uc); } }
c# asp.net gridview webforms
No comments:
Post a Comment