Solved

asp.net, C#, Ajax.

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Paging GridView 7 34
Refresh Datagridview from another form 1 28
ASP.net VB.net Email  a webpage 3 26
Birthdays 3 21
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

746 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

9 Experts available now in Live!

Get 1:1 Help Now