how does one limit postback to a small section of screen?

  • Thread starter Thread starter COHENMARVIN
  • Start date Start date
C

COHENMARVIN

I have a checkbox on my webpage which, if checked, should cause a
textbox to be enabled (or made visible). But I find I need to make
the checkbox have a autopostback of TRUE for this to work. Is there
any way, perhaps using Ajax update panels, to have a checkbox cause a
partial postback of only part of the page?
Thanks,
Marvin
 
this should be done in javascript, not ajax. no need to postback (may take a
couple seconds on the internet) just unhide or enable a control.

<script>
function setText(e)
{
var t= document.getElementById('<%=myTextbox.ClientID%>');
t.disabled = !e.checked;
}
</script>
<asp:checkbox id="chk" runat="server" onclick="setText(this);"/><br>
<asp:textbox id="myTextbox" runat="server" Enabled="false" />

-- bruce (sqlwork.com)
 
Bruce is right that you can do this more efficiently by using only client
side JavaScript.

You are also right that it could be done gracefully with an AJAX
UpdatePanel. This would be less efficient because it requires a round trip
to the server, but if you fear JavaScript then it would be the simpler
solution for you. If your app doesn't need to be optimized for scalability
then this solution would likely be sufficient.

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
http://iPhonePlaza.net
 
Back
Top