In theory, PreviousPage lets you admission abstracts on the folio the user aloof requested. In convenance it doesn’t assignment if you’re additionally application Master Pages unless you accept ASP.NET allotment containers.
Once you admission at the ambition page, you can use its PreviousPage acreage to ability aback to a ascendancy on the antecedent folio and retrieve its data.
In theory, as continued as you don’t get to the ambition folio application Response.Redirect, you should be able to ability aback to the aboriginal folio and retrieve the argument from a ascendancy alleged NameTextBox with this code:
ct = Me.PreviousPage.FindControl(“NameTextBox”) customerName = CType(ct, TextBox).Text
However, you can get FindControl to do its job if you aloof alpha at the appropriate abode in your folio structure.
Working with Allotment ContainersI’ll alpha with the basics: a ascendancy on a folio that isn’t application a Master Page. If you accept a argument box alleged TextBox, this command will acknowledgment a advertence to the argument box:
The aforementioned cipher will assignment alike if TextBox1 is central a Panel. But if the argument box is central an ASP.NET FormView, this cipher will fail. Instead, you charge to alarm FindControl from the FormView itself:
Obviously, while FindControl is accommodating to assignment bottomward through a Panel back hunting for a control, it’s not accommodating to attending central every affectionate of alembic on a form.
The aphorism is that FindControl banned its chase to the accepted “naming container” — any ascendancy that accouterments the INamingContainer interface. Your ASP.NET folio is a allotment container, for instance, and Panels aren’t, so FindControl will attending central a Panel on the page. FormViews, on the added hand, are allotment containers so FindControl won’t attending central them back alleged from the Page.
Naming containers are those controls that extend the client-side name of any ascendancy placed central them. For instance, a TextBox will accomplish an HTML tag with a absence id aspect set to the aforementioned amount as the TextBox’s id property:
Place the TextBox central a Panel and the HTML tag generated charcoal the same. But abode the TextBox central a allotment alembic like the FormView and the HTML tag’s id aspect will be continued with the name of the container, like this:
FindControl on Master PagesSo what about Master Pages and agreeable pages? The acceptable account first: Award a ascendancy on a Master Folio is accessible (assuming that the ascendancy isn’t central a FormView, of course). From cipher in your agreeable page, you can aloof use the PreviousPage’s Master acreage to admission the Master Folio and retrieve a control:
However, award the aforementioned ascendancy on the agreeable folio based on the Master Folio through PreviousPage is added difficult. A TextBox with an id of TextBox4 central a Agreeable ascendancy angry to ContentPlaceHolder1 will accept its id aspect continued like this:
The solution, as with the FormView, is to alarm FindControl from the allotment alembic — in this case, the Agreeable control. The botheration is that Agreeable controls, clashing FormViews, don’t arise as a acreage on either the Folio or PreviousPage. To get to the Agreeable control, you’ll accept to assignment bottomward through the Page’s Controls collection.
If you appraise the Contents accumulating of a agreeable page, you’ll acquisition that the folio has a distinct control. That control, in turn, contains bristles controls and the fourth ascendancy has its id acreage set to “form1.” Obviously, this is the ascendancy that represents the HTML anatomy that contains all the controls on the page.
Stay with me; I do accept a point and I’m accepting to it. Central the ascendancy that represents the anatomy are the Agreeable controls on the page. This cipher will retrieve the aboriginal Agreeable ascendancy through the PreviousPage property:
This is appealing animal cipher — and you apperceive that all those hard-coded accumulation ethics are activity to be a daydream to maintain. For instance, if you add a additional ContentPlaceHolder to your Master Page, which of those numbers will change?
Don’t panic! You can additionally use FindControl to locate your Agreeable control. This code will acquisition the Agreeable ascendancy by name and again find, by name, a ascendancy central of it (and the one actual accumulation in this cipher will never change). It still isn’t appealing code. But it does work. And now you can use PreviousPage with Master Pages.
Peter Vogel is a arrangement artist and arch in PH&V Information Services. PH&V provides full-stack consulting from UX architecture through article clay to database design. Peter tweets about his VSM columns with the hashtag #vogelarticles. His blog posts on user acquaintance architecture can be begin at http://blog.learningtree.com/tag/ui/.
How To Get People To Like Html Form Text Box | Html Form Text Box – html form text box
| Pleasant to help our blog, on this occasion We’ll teach you in relation to html form text box