Solved

Best method to use in developing a Visual Studio web application - multiview or webforms to replicate tab control from winforms?

Posted on 2016-08-09
7
31 Views
Last Modified: 2016-08-09
I have a data entry screen in a winform that has 12 tabs to perform entry.  I am converting this application to a webform and need the best method to recreate the 12 tabs.  

Using the multiview option, when I move to view=1 and choose something from a listbox, it takes me back to view=0.   I added the EnableViewState=False and that screen worked okay but when I went back to view-0, my listboxes weren't populating correctly, so I went back to the drawing board.  I created another webform for the "second tab."  That works fine and the labor is the same to no biggie until I need to save.  I feel a nightmare coming on.  I also want to use this form(s) for editing a record.

Any advice for the best plan of attack?
0
Comment
Question by:Karen Wilson
  • 4
  • 3
7 Comments
 
LVL 12

Accepted Solution

by:
funwithdotnet earned 500 total points
ID: 41749108
This is an "easy" one.

I use two divs. The top div ("tabs") holds the tabs, the bottom div ("tabPages") has a div for each tab (tab1page, tab2page, etc.) . Show & hide the [tab#page] divs  based on user input. All controls are always there. You can have javascript, server-side, and viewstate on all controls.

Some controls have large amounts of viewstate data. If you put too many "heavy" controls on a single page, the viewstate data (that goes upstream) can get a bit ridiculous. If performance is good, you can usually ignore the size of the viewstate.

Good luck!
0
 

Author Comment

by:Karen Wilson
ID: 41749139
I have a menu for all the tabs so I should be able to just reference the div, right?  I Id'd the div like this:   <div id="Information">

I only want this div to appear on the startup of this data entry. How do I do that?
0
 

Author Closing Comment

by:Karen Wilson
ID: 41749177
I figured it out.  Thanks for putting me on the right path.

   <div id="div_Require" runat="server">  I had to runat the server.

On my page load I have this code:

 Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        UnobtrusiveValidationMode = System.Web.UI.UnobtrusiveValidationMode.None

        c = Environ("username")

        If Not IsPostBack Then
            Dim getRspOff = (From id In d.tblDepts _
                                 Group By ro = id.RespOffice Into Group _
                                 Order By ro Ascending _
                                 Select ro).ToList

            Me.PMComboBox.DataSource = getRspOff
            Me.PMComboBox.DataBind()
        End If

        div_Information.Visible = True
        div_Require.Visible = False

    End Sub

All seems to be working well so far!  Thanks again.
Karen
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:Karen Wilson
ID: 41749184
I guess I spoke too soon!  When I move to the second div on the page, when I select something in a list box, it makes me back to the first div.  Do I need to open another question?
0
 
LVL 12

Expert Comment

by:funwithdotnet
ID: 41749247
Do you have an event associated with the listbox selection?

Remember that some controls persist their values but not their source data on postback. The data may need to be re-bound on every trip for viewstate to be restored.
0
 

Author Comment

by:Karen Wilson
ID: 41749264
The listbox is filled by editing the items.  When one/multiple item(s) is selected, the values are added to a textbox, where the user can then fill in more information.  The textbox is used to update the record when saved.  The listbox has the Enable Auto Postback selected.


Protected Sub ListBox14_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox14.SelectedIndexChanged
        Me.txtCustAgree.Text = CStr(ListBox14.SelectedItem.Value)
End Sub
0
 
LVL 12

Expert Comment

by:funwithdotnet
ID: 41749333
So it seems that when the listbox index changes, a postback happens, but some controls aren't recreating their previous environment.

I'm not sure about the combobox. Some data sources do not persist and will be empty after postback. You might want to populate them with every postback.

If you debug and step through your code, sniffing values as you go (hover the cursor over an object name), you can see exactly what is happening when in the lifecycle. Remember that a web application has already died when it's returned to the browser. A postback causes a new application to run. Viewstate helps re-create the state from the previous application execution. You have to do the rest yourself.

Also, document.getElementById("elementId") from the HTML DOM is one of my best friends. Javascript can do wonders with it without a postback.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question