Solved

asp.net, C#, Ajax.

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
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 …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

740 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