Solved

asp.net, C#, Ajax.

Posted on 2014-11-10
4
206 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
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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Question! 4 36
VB: Convert 2 dates to specific format 24 48
object oriented design (python) and documentation tools 2 43
backup program with robocopy 6 21
A short article about problems I had with the new location API and permissions in Marshmallow
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
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 …

809 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