Solved

asp.net, C#, Ajax.

Posted on 2014-11-10
4
211 Views
Last Modified: 2014-12-02
_SelectedIndexChanged

Hiexperts, I am trying to visible and invisible a few questions based on the selected item they choose from a radio button list. Is tehre anything I am missing, it works well if I use Enabled and disable, but i wanted to have it visible and invisible.
this is some part of the code i have.

protected void rdlPregnant_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (rdlPregnant.Items[0].Selected)
        {
             rdbPrenatalCare.Enabled = true;
            rdbGainWeight.Enabled = true
   
        }
else {
            else
        {

            rdbPrenatalCare.Enabled = false;
            rdbGainWeight.Enabled = false;
        }
I am using ajax as well.


             <telerikAJAX:AjaxSetting AjaxControlID="rdlPregnant">
              <UpdatedControls>
              <telerikAJAX:AjaxUpdatedControl ControlID="rdbPrenatalCare" LoadingPanelID="AjaxLoadingPanel1" />
              </UpdatedControls>
          </telerikAJAX:AjaxSetting>
I have more questions to make it invisible. not just radio buttons but also labels in asp.net. When I change the selected index, the control no longer works.
any suggestion.
0
Comment
Question by:shpresa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 5

Assisted Solution

by:Ronak Patel
Ronak Patel earned 250 total points
ID: 40434387
Please provide more details on the issue you are facing..
mean while, try below code :

protected void rdlPregnant_SelectedIndexChanged(object sender, EventArgs e)
{
	if (rdlPregnant.Items[0].Selected)
	{
		rdbPrenatalCare.Visible = true;
		rdbGainWeight.Visible = true;
	}
	else
	{
		rdbPrenatalCare.Visible = false;
		rdbGainWeight.Visible = false;
	}
}

Open in new window

0
 

Author Comment

by:shpresa
ID: 40435440
I did tried that coding. The problem is that when I switch from Item[0] to item[1],visible or invisible no longer works.
0
 
LVL 14

Accepted Solution

by:
CtrlAltDl earned 250 total points
ID: 40447755
Just make sure any controls you are trying to hide or unhide MUST be inside the same AJaxUpdateControl.  If they are not inside the UpdateControl then you must put it in it's own UpdateControl and trigger an update from the SelectedIndexChanged event.

Otherwise they will only hide or unhide if you do a complete PostBack.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

705 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