How do I call server side function in client side script without using __doPostBack

Hello,

My page has a server side panel that is hidden when the page loaded, checkboxes inside of the datagrid, and buttons.  If at least one checkbox is not clicked and the user click on the button, I show the panel.  When the user click on one of the checkbox, I want to hide the panel.  Onclick on the checkbox I already have a cleint function to change the row color. 

I don't want to use __doPostBack.  Don't want to do postback.

My question are:
How do I either have checkbox onclick called both client and server side functions. 
Or have the client side function call the server side function to hide the panel.

Thank you

0
kathy9999
11/17/2005 7:52:53 PM
asp.net.client-side 24353 articles. 2 followers. Follow

4 Replies
1460 Views

Similar Articles

[PageSpeed] 12
Get it on Google Play
Get it on Apple App Store

Hi Kathy - 

If you have a Panel with the ID of pnlError, and a CheckBox with the id of chkRow, you could use the following logic (in the Page Load event)

I'm assuming VB, let me know if you need C#

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

       chkRow.Attributes.Add("onClick", "document.getElementById('" & pnlError.ClientID & "').style.display='none';")

    End Sub

To show the panel, use style.display='';


0
TylerFree
11/17/2005 9:16:14 PM

Tyler,

Thank you for the tip.  It works, but..

I already have the onClick atttributes added for client side for something else.  Can I have the OnClick doing more than one?

' add on click to each checkbox
' chkSelect.Attributes.Add("OnClick", "javascript:colorRow(event)")

  chkSelect.Attributes.Add("onClick", "document.getElementById('" & ErrorMessage.ClientID & "').style.display='none';")

Thanks again

0
kathy9999
11/18/2005 3:39:31 AM
 kathy9999 wrote:
I already have the onClick atttributes added for client side for something else. Can I have the OnClick doing more than one?


Sure you can. Just seperate the statements using a semicolon.

chkSelect.Attributes.Add("onclick", string.Format("colorRow(event);document.getElementById('{0}').style.display='none';", ErrorMessage.ClientID))

--
Tarjei
0
tarjei
11/18/2005 10:07:23 AM
It works.  

Thank you so much for the code.  You saved me hours of research time.
0
kathy9999
11/18/2005 3:12:25 PM
Reply: