Solved

asp.net, C#, Ajax.

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
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 …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

867 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now