Viewstate issue when loading user controls dynamically

I have an .aspx file that I load different user controls onto depending on what link the user clicks on. I have everything working just fine at this point. Please see the following question for reference:
http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_25275657.html
I came across an issue and needed to add some javascript to one of my user controls, this is where I discovered an even bigger problem:

When I view source on the page with one of my user controls, I don't see the current user control at all. I did some checking and found a post where someone had written a similar project that the "view source" DID show the correct user control.(http://www.aspnet4you.com/Articles.aspx?ArticleID=5032) I did some testing and found that if I put the following line in my web.config:
<xhtmlConformance mode="Legacy"/>
the "view source" showed correctly. After googleing to see what exactly this line did:
http://weblogs.asp.net/scottgu/archive/2006/12/10/gotcha-don-t-use-xhtmlconformance-mode-legacy-with-asp-net-ajax.aspx
I found that it wasn't a good fix at all. My update panels do NOT work correctly.
After some consideration, the project I named above was written in framework 2.0(I upgraded when I ran it on my machine), my project is framework 3.5.

Does anyone know how to get my framework 3.5 project to render the viewstate properly(as it used to in framework 2.0)?
leylAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PaulHewsCommented:
>When I view source on the page with one of my user controls, I don't see the current user control at all.

Do you mean that your control shows in the page but does not appear in the HTML view?  Or do you mean that it doesn't show in the viewstate...  If you mean the latter, how do you know that it doesn't appear in the viewstate?
0
leylAuthor Commented:
Thank you very much for your response.
Nothing within the user control appears in the HTML view.
I tried to put a small javascript function within the user control and it threw an error, so I viewed the source from the browser and realized that none of the user control was there.
I would not have realized this if it wasn't for the javascript, because everything else works fine. I am able to see everything I need from the code behind on post back.
I wasn't sure if this was a "viewstate" issue or not. I just know that the HTML is not being rendered correctly some how.

Thanks again
0
leylAuthor Commented:
Let me clarify a little:

The rendered page is fine(UI), when I right click and select "View Source", I do not see any of the html(static, or otherwise) that exists within the user control.
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

PaulHewsCommented:
If the user control is showing in the browser window it has to be rendered in the source.  It's possible that you are searching using the ID that you gave it in Visual Studio, but the ASP.NET engine will render a new ID that will be quite different.
0
leylAuthor Commented:
I have attached a screen shot, the html code for the user control, and the txt file from "View Source"

Below is the .aspx page html. I took out all databinding and tried to make it simple.

<form id="form1" runat="server">
    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </asp:ToolkitScriptManager>
    <div>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">
    <ContentTemplate>
    <div style="text-align:center;">
        <table border="0" cellpadding="0" cellspacing="0" width="890px">
            <tr>
                <td style="padding-left:25px;">
                    <cc2:C1TabStrip ID="TabStripMain" runat="server" Width="890px" VisualStyle="Office2007Blue" Alignment="Left" AutoPostBack="true">
                        <Tabs>
                            <cc2:C1Tab ID="tabContact" runat="server" Text="Contact Information"></cc2:C1Tab>
                            <cc2:C1Tab ID="tabConsent" runat="server" Text="Informed Consent"></cc2:C1Tab>
                            <cc2:C1Tab ID="tabNew" runat="server" Text="New Test"></cc2:C1Tab>
                        </Tabs>
                    </cc2:C1TabStrip>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:PlaceHolder ID="hold" runat="server"></asp:PlaceHolder>
                </td>
            </tr>
        </table>
    </div>
    </ContentTemplate>
    </asp:UpdatePanel>
    </div>
    </form>
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="ContactInformation.ascx.vb" Inherits="DynamicTest.ContactInformation" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>

<script language="javascript" type="text/javascript">
    function ShowHidePrefer(phoneType) {
        var chk = 'chkPrefer' + phoneType + 'Phone';
        var tr = 'trPrefer' + phoneType + 'Phone';
        if (document.getElementById(preId + chk).checked) {
            document.getElementById(preId + tr).style.display = 'inline';
        }
        else {
            document.getElementById(preId + tr).style.display = 'none';
        }
    }
    function SetColumns() {
        alert(document.getElementById('txtNumPregnancies'));
    }
</script>

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table border="0" cellpadding="0" cellspacing="0">
    <tr valign="top" style="padding-top:10px;">
        <td align="left">
            <table border="0" cellpadding="2" cellspacing="0">
                <tr>
                    <td align="right">FIRST NAME:</td>
                    <td>
                        <asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td align="right">PREFERRED NAME:</td>
                    <td>
                        <asp:TextBox ID="txtPreferred" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td align="right">MIDDLE NAME or INITIAL:</td>
                    <td>
                        <asp:TextBox ID="txtMiddleName" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td align="right">LAST NAME:</td>
                    <td>
                        <asp:TextBox ID="txtLastName" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td align="right">MAIDEN NAME:</td>
                    <td>
                        <asp:TextBox ID="txtMaidenName" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td align="right">PARTNER'S LAST NAME:</td>
                    <td>
                        <asp:TextBox ID="txtPartnerLastName" runat="server"></asp:TextBox>
                    </td>
                </tr>
            </table>
        </td>
        <td style="width:10px;">&nbsp;</td>
        <td align="center">
            <table border="0" cellpadding="2" cellspacing="0">
                <tr>
                    <td style="border-bottom:solid 1px black;"><b>Prefer</b></td>
                    <td colspan="3"><b>Phone Numbers</b></td>
                </tr>
                <tr>
                    <td style="width:50px;">
                        <asp:CheckBox ID="chkPreferHomePhone" runat="server" />
                    </td>
                    <td style="width:90px;text-align:right;">Home Phone:</td>
                    <td>
                        <asp:TextBox Id="txtHomePhone" runat="server" Width="75px"></asp:TextBox>
                        <ajax:MaskedEditExtender ID="meeHomePhone" runat="server" TargetControlID="txtHomePhone" MaskType="None" Mask="(999)999-9999"></ajax:MaskedEditExtender>
                    </td>
                    <td style="width:130px;text-align:left;">
                        <b>Ext.:</b><asp:TextBox ID="txtHomePhoneExt" runat="server" Width="50px"></asp:TextBox>
                    </td>
                </tr>
                <tr id="trPreferHomePhone" runat="server" style="display:none;">
                    <td>&nbsp;</td>
                    <td colspan="3">
                        <asp:CheckBoxList ID="cblPreferHomePhone" runat="server" RepeatDirection="Horizontal">
                            <asp:ListItem Value="812" Text="8-12am"></asp:ListItem>
                            <asp:ListItem Value="123" Text="12-3pm"></asp:ListItem>
                            <asp:ListItem Value="36" Text="3-6pm"></asp:ListItem>
                            <asp:ListItem Value="6" Text="After 6pm"></asp:ListItem>
                        </asp:CheckBoxList>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:CheckBox ID="chkPreferWorkPhone" runat="server" />
                    </td>
                    <td align="right">Work Phone:</td>
                    <td>
                        <asp:TextBox ID="txtWorkPhone" runat="server" Width="75px"></asp:TextBox>
                        <ajax:MaskedEditExtender ID="meeWorkPhone" runat="server" TargetControlID="txtWorkPhone" MaskType="None" Mask="(999)999-9999"></ajax:MaskedEditExtender>
                    </td>
                    <td align="left">
                        <b>Ext.:</b><asp:TextBox ID="txtWorkPhoneExt" runat="server" Width="50px"></asp:TextBox>
                    </td>
                </tr>
                <tr id="trPreferWorkPhone" runat="server" style="display:none;">
                    <td>&nbsp;</td>
                    <td colspan="3">
                        <asp:CheckBoxList ID="cblPreferWorkPhone" runat="server" RepeatDirection="Horizontal">
                            <asp:ListItem Value="812" Text="8-12am"></asp:ListItem>
                            <asp:ListItem Value="123" Text="12-3pm"></asp:ListItem>
                            <asp:ListItem Value="36" Text="3-6pm"></asp:ListItem>
                            <asp:ListItem Value="6" Text="After 6pm"></asp:ListItem>
                        </asp:CheckBoxList>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:CheckBox ID="chkPreferCellPhone" runat="server" />
                    </td>
                    <td align="right">Cell Phone:</td>
                    <td>
                        <asp:TextBox ID="txtCellPhone" runat="server" Width="75px"></asp:TextBox>
                        <ajax:MaskedEditExtender ID="meeCellPhone" runat="server" TargetControlID="txtCellPhone" MaskType="None" Mask="(999)999-9999"></ajax:MaskedEditExtender>
                    </td>
                    <td>&nbsp;</td>
                </tr>
                <tr id="trPreferCellPhone" runat="server" style="display:none;">
                    <td>&nbsp;</td>
                    <td colspan="3">
                        <asp:CheckBoxList ID="cblPreferCellPhone" runat="server" RepeatDirection="Horizontal">
                            <asp:ListItem Value="812" Text="8-12am"></asp:ListItem>
                            <asp:ListItem Value="123" Text="12-3pm"></asp:ListItem>
                            <asp:ListItem Value="36" Text="3-6pm"></asp:ListItem>
                            <asp:ListItem Value="6" Text="After 6pm"></asp:ListItem>
                        </asp:CheckBoxList>
                    </td>
                </tr>
                <tr valign="top">
                    <td>
                        <asp:CheckBox ID="chkPreferTextMessage" runat="server" />
                    </td>
                    <td colspan="3" align="left">Text Message<br />
                        <span style="font-size:8pt;">* Text messages will be used strictly for reminders,<br />not as a method of contact</span>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:CheckBox ID="chkPreferBeeperPhone" runat="server" />
                    </td>
                    <td align="right">Beeper:</td>
                    <td>
                        <asp:TextBox ID="txtBeeperPhone" runat="server" Width="75px"></asp:TextBox>
                        <ajax:MaskedEditExtender ID="meeBeeperPhone" runat="server" TargetControlID="txtBeeperPhone" MaskType="None" Mask="(999)999-9999"></ajax:MaskedEditExtender>
                    </td>
                    <td>&nbsp;</td>
                </tr>
                <tr id="trPreferBeeperPhone" runat="server" style="display:none;">
                    <td>&nbsp;</td>
                    <td colspan="3">
                        <asp:CheckBoxList ID="cblPreferBeeperPhone" runat="server" RepeatDirection="Horizontal">
                            <asp:ListItem Value="812" Text="8-12am"></asp:ListItem>
                            <asp:ListItem Value="123" Text="12-3pm"></asp:ListItem>
                            <asp:ListItem Value="36" Text="3-6pm"></asp:ListItem>
                            <asp:ListItem Value="6" Text="After 6pm"></asp:ListItem>
                        </asp:CheckBoxList>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr><td>&nbsp;</td></tr>
    <tr valign="top">
        <td>
            <asp:Panel ID="pnlAddresses" runat="server" Width="450px">
                <table border="0" cellpadding="0" cellspacing="0">
                    <tr style="height:20px;vertical-align:middle;font-weight:bold;background-color:#7ca492;">
                        <td align="center" style="font-size:10pt;">
                            Mailing Addresses
                        </td>
                    </tr>
                </table>
            </asp:Panel>
            <ajax:RoundedCornersExtender ID="RoundedCornersExtender1" runat="server" TargetControlID="pnlAddresses" Enabled="true" Color="#7ca492" BorderColor="#7ca492" Corners="All" Radius="6">
            </ajax:RoundedCornersExtender>
        </td>
        <td style="width:10px;">&nbsp;</td>
        <td>
            <asp:Panel ID="pnlEmail" runat="server" Width="325px">
                <table border="0" cellpadding="0" cellspacing="0">
                    <tr style="height:20px;vertical-align:middle;font-weight:bold;background-color:#7ca492;">
                        <td align="center" style="font-size:10pt;">
                            Email Addresses
                        </td>
                    </tr>
                </table>
            </asp:Panel>
            <ajax:RoundedCornersExtender ID="RoundedCornersExtender2" runat="server" TargetControlID="pnlEmail" Enabled="true" Color="#7ca492" BorderColor="#7ca492" Corners="All" Radius="6">
            </ajax:RoundedCornersExtender>
        </td>
    </tr>
    <tr><td>&nbsp;</td></tr>
    <tr>
        <td>
            <asp:Panel ID="pnlSpecial" runat="server" Width="458px">
                <table border="0" cellpadding="0" cellspacing="0">
                    <tr style="height:20px;vertical-align:middle;font-weight:bold;background-color:#7ca492;">
                        <td align="center" style="font-size:10pt;">
                            Special Instructions
                        </td>
                    </tr>
                    <tr style="height:20px;vertical-align:middle;">
                        <td align="center" style="font-size:8pt;">
                            Are there any special instructions when trying to contact you<br />
                            or when leaving a message for you?
                        </td>
                    </tr>
                </table>
            </asp:Panel>
            <ajax:RoundedCornersExtender ID="RoundedCornersExtender3" runat="server" TargetControlID="pnlSpecial" Enabled="true" Color="#7ca492" BorderColor="#7ca492" Corners="All" Radius="6">
            </ajax:RoundedCornersExtender>
        </td>
        <td style="width:10px;">&nbsp;</td>
        <td>
            <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td colspan="2">Did someone refer you to the Contraceptive CHOICE Project?</td>
                </tr>
                <tr>
                    <td>
                        <asp:RadioButtonList ID="rblRefer" runat="server" RepeatDirection="Horizontal">
                            <asp:ListItem Value="True" Text="Yes"></asp:ListItem>
                            <asp:ListItem Value="False" Text="No"></asp:ListItem>
                        </asp:RadioButtonList>
                    </td>
                </tr>
                <tr>
                    <td>
                        If yes, who: <asp:TextBox ID="txtReferWho" runat="server" Width="300px"></asp:TextBox>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr><td>&nbsp;</td></tr>
    <tr valign="top">
        <td>
            <asp:Panel ID="pnlContacts" runat="server" Width="452px">
                <table border="0" CellPadding="0" CellSpacing="0">
                    <tr style="height:20px;vertical-align:middle;font-weight:bold;background-color:#7ca492;">
                        <td align="center" style="font-size:10pt;">
                            Contacts
                        </td>
                    </tr>
                    <tr style="vertical-align:middle;">
                        <td align="center" style="font-size:8pt;padding:5px;">
                            We would like to ask you for contact information for individuals that<br />
                            would know how to reach you if we cannot reach you using the<br />
                            information you provided earlier.  This could be someone who does<br />
                            not live in your household but who would know how to contact you,<br />
                            for example a friend, or neighbor, or a family member.  As I told you<br />
                            earlier, this information will be kept strictly confidential and only<br />
                            used to help us contact you for study purposes.
                        </td>
                    </tr>
                    <tr>
                        <td align="left" style="font-size:8pt;padding:5px;">
                            <b>IF MARRIED/PARTNERED:</b> Ask for spouse/partner's first and last<br />
                            name, phone number and address.<br />
                            <b>IF A MINOR:</b> Ask for parent or guardian's first and last name,<br />
                            phone number and address.
                        </td>
                    </tr>
                </table>
            </asp:Panel>
            <ajax:RoundedCornersExtender ID="RoundedCornersExtender4" runat="server" TargetControlID="pnlContacts" Enabled="true" Color="#7ca492" BorderColor="#7ca492" Corners="All" Radius="6">
            </ajax:RoundedCornersExtender>
        </td>
        <td style="width:10px;">&nbsp;</td>
        <td align="center">
            <asp:Panel ID="pnlPhysicians" runat="server" Width="380px">
                <table border="0" cellpadding="0" cellspacing="0">
                    <tr style="height:20px;vertical-align:middle;font-weight:bold;background-color:#7ca492;">
                        <td align="center" style="font-size:10pt;">
                            Physicians
                        </td>
                    </tr>
                    <tr>
                        <td style="font-size:8pt;padding:5px;">
                            What is the name of the doctor/health care provider<br />
                            or clinic name where you seek reproductive health (gynecologic) care?
                        </td>
                    </tr>
                </table>
            </asp:Panel>
            <ajax:RoundedCornersExtender ID="RoundedCornersExtender5" runat="server" TargetControlID="pnlPhysicians" Enabled="true" Color="#7ca492" BorderColor="#7ca492" Corners="All" Radius="6">
            </ajax:RoundedCornersExtender>
        </td>
    </tr>
    <tr><td>&nbsp;</td></tr>
    <tr>
        <td colspan="3">
            <asp:Button ID="btnSubmitPage" runat="server" Text="Submit Changes" />
        </td>
    </tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>

Open in new window

ScreenShot.gif
ViewSource.txt
0
PaulHewsCommented:
I'm guessing that it's a feature of the c1tabcontrol and how it loads content dynamically.   It seems to be using AJAX to build the content, which explains why it doesn't show up in your source.  The real issue (the script error) might not be related.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
leylAuthor Commented:
Good thought.

It doesn't make sense to me because the user controls don't actually reside inside the tabstrip control. It must have a bunch of ajax compiled with it that messes other stuff up.
I replaced the tabstrip control with a dropdownlist and had no issue. I just wouldn't have thought that would be the problem.

Thank you so much for helping me with this. I truly appreciate it.
0
leylAuthor Commented:
After much going back and forth, It was not the C1tabControl causing the problem, it is the UpdatePanel.
I have yet to find a real fix for this.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.