Link to home
Start Free TrialLog in
Avatar of amillyard
amillyardFlag for United Kingdom of Great Britain and Northern Ireland

asked on

c# asp using the .style.visibility server-side (aspx.cs)

Development Platform: c#, asp.net 2.x, Visual Studio Pro utilising Web Developer, IIS 6, SQL Server 2005

the following script line is working fine within the .aspx form, can make the DropDownList visible or hidden).

onclick="document.getElementById('DropDownList_StaffMembers').style.visibility = 'hidden';"

how do I perform this action from the server-side of things...i.e. inside a PreRender procedure?

        protected void Page_PreRender(object sender, EventArgs e)
        {
            ViewState["_isChecked"] = RadioButton_Role.Checked;

            if (Convert.ToBoolean(ViewState["_isChecked"]))
            {
                RadioButton_Role.Checked = true;
                RadioButton_StaffMember.Checked = false;
                DropDownList_StaffMembers.style.visibility = "hidden";   //this line is not compiling
            }
            else
            {
                RadioButton_Role.Checked = false;
                RadioButton_StaffMember.Checked = true;
                DropDownList_StaffMembers.style.visibility = 'visible';    //this line is not compiling
            }
        }


thank you in advance for your time and efforts with this enquiry.
SOLUTION
Avatar of strickdd
strickdd
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of amillyard

ASKER

@strickdd

I am getting the following compilier error as follows:

'System.Web.UI.WebControls.DropDownList' does not contain a definition for 'style'
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@dstanley9

yes, this certainly works ... but, when I click on the radio button again, it refuses to reappear -- I suspect its because the above visibility is the overall visibility control setting?

below is the script I use on the form to hide and show the drop down list, depending on which radio button you select.

as is stands now, when the page refreshes and gets pre-rendered, the drop down list now disappears and remains that way -- even with the radio button to select option again is used.

your thoughts are much apprieated.

                        <td style="width: 366px">
                            <asp:RadioButton ID="RadioButton_Role" runat="server" Font-Size="X-Small" GroupName="PipelineSpoolerTask" Text="Role" onclick="document.getElementById('DropDownList_StaffMembers').style.visibility = 'hidden';"/>
                            <asp:RadioButton ID="RadioButton_StaffMember" runat="server" Font-Size="X-Small" GroupName="PipelineSpoolerTask" Text="Staff Member" onclick="document.getElementById('DropDownList_StaffMembers').style.visibility = 'visible';" Checked="True" />&nbsp;
                            <asp:DropDownList ID="DropDownList_StaffMembers" runat="server" DataSourceID="SqlDataSource_StaffMembers"
                                DataTextField="DisplayName" DataValueField="CompanyAgent_ID">
                            </asp:DropDownList>
                        </td>
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial