Refresh Not Happening

W

Wayne Wengert

I have an aspx page on which I trap a change in the selected radiobutton in
a radiobuttonlist. In that event code, I change the visibility of some
controls based on what button was selected. The change to the objects made
in that routine does not take effect until the user clicks on another
control (button or such)

How can I get those changes to be immediately visible? I don't see anything
like a Refresh?

TIA

Wayne
 
D

David Barkol

Solution 1:

You need to register a javascript function for the onclick and onchange
events.

Example:

<asp:radiobuttonlist id="RadioList1" onclick="RadioList1_Click();"
onchange="RadioList1_Click();" RepeatColumns="2" RepeatLayout="Flow"
Runat="server">

In the 'RadioList1_Click' function you can then set the style.display
value to ' ' or 'none' for the controls you want to display.

Solution 2:
If you rather do this on the server side then you will need a post back
and you can just call Response.Redirect to refresh the page.

David Barkol
www.neudesic.com
 
A

Anders K. Jacobsen [DK]

Solution 2:
If you rather do this on the server side then you will need a post back
and you can just call Response.Redirect to refresh the page.

Soultion 3:

In your class you declare a bool eg. HideMyElements = false;

In your event handler for the radiobutton list you set HideMyElements =
true;

Now the essential part. You can still manage to get your update with the
request if you declare

protected override OnPreRender(......)
{
if(HideMyElements )
{
control.visible = false;
}
}

Hope I undestood your question

Regards
Anders Jacobsen
 
W

Wayne Wengert

Thanks guys. I plan to experiment with a couple of those suggestions to see
if I understand them I have very little javascript knowledge so this will be
a chance to try out some things.

Wayne
 
W

Wayne Wengert

David;

I tried to apply the suggestion to register the JavaScript function but the
"onclick" and "onchange" clauses get flagged as "could not find any onclick
attribute for radiobuttonlist?

Wayne
 
D

David Barkol

Wayne said:
David;

I tried to apply the suggestion to register the JavaScript function but the
"onclick" and "onchange" clauses get flagged as "could not find any onclick
attribute for radiobuttonlist?

Wayne

Don't worry about the flag, it will work. Throw an alert up in the
function to confirm.

- David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top