Results 1 to 4 of 4

Thread: client side script

  1. #1

    Thread Starter
    Addicted Member jewel's Avatar
    Join Date
    Jul 2003
    Location
    truly asia
    Posts
    153

    client side script

    Hi,

    can anyone show me how to handle client side script with asp.net? make sense? how will client side script communicate with code behind?


    Thanks,

    Jewel
    xoxo

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: client side script

    You can use two methods: Page.RegisterStartupScript to make some js run immediately, or Page.RegisterClientScriptBlock to add some javascript to your page. You generate the javascript in the codebehind with your controls, or whatever logic you want.

  3. #3

    Thread Starter
    Addicted Member jewel's Avatar
    Join Date
    Jul 2003
    Location
    truly asia
    Posts
    153

    Re: client side script

    hi, thanks...can you give me an example please...
    xoxo

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: client side script

    Example:

    VB Code:
    1. Dim strJS As String
    2.         strJS = "<script language=JavaScript>function selectAll(intAction){" & _
    3.                 "if(intAction==0)" & _
    4.                 "{"
    5.         For i As Integer = 0 To strArrayA.GetUpperBound(0)
    6.             strJS &= "document.getElementById('" & strArrayA(i).ToString() & "').checked = true;"
    7.         Next
    8.  
    9.         strJS &= "}" & _
    10.                 "else" & _
    11.                 "{"
    12.  
    13.         For j As Integer = 0 To strArrayD.GetUpperBound(0)
    14.             strJS &= "document.getElementById('" & strArrayD(j).ToString() & "').checked = true;"
    15.         Next
    16.  
    17.         strJS &= "}}</script>"
    18.  
    19.  
    20.  
    21.         Page.RegisterClientScriptBlock("theselectallfunction", strJS)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width