?
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
Medium Priority
?
48 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 2000 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses
Course of the Month17 days, 2 hours left to enroll

862 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