in Search
     
Latest post 03-13-2008 7:16 AM by JehPopoy. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 03-12-2008 3:20 AM

    calling a javascript function inside a CODE BEHIND sub procedure

    mga kuya pano po ba or pwede bang tumawag ng javascript function sa loob ng code behind Sub procedure? VB po

     ex.

     Public Sub blahblah ()

    ...........some vb codes

    -----> CALL JAVASCRIPT FUNCTION<---------

    ...........some vb codes THAT RETRIEVES A VALUE from the JAVASCRIPT FUNCTION is RECENTLY CALLED

    ...........some vb codes

    end sub

    ------------------------

    ex. calling a 'confirmation dialogbox'

     

    two days na ko nag hahanap sa web pero hindi ganung structure yung tinuturo nila...

     salamat po

    • Post Points: 35
  • 03-12-2008 6:10 AM In reply to

    • JehPopoy
    • Top 150 Contributor
    • Joined on 02-25-2008
    • Posts 8
    • Points 215

    Re: calling a javascript function inside a CODE BEHIND sub procedure

    hi kuya,

        Hinde un pwede tsong. though may ibang paraan para makagpasa ng data sa dalawang code. Isa na dito ung paggamit ng mga hidden fields at pagreregister ng javascript via server scripts. 

    • Post Points: 5
  • 03-12-2008 8:11 AM In reply to

    • keithrull
    • Top 10 Contributor
    • Joined on 08-08-2005
    • San Diego, CA
    • Posts 1,956
    • Points 39,255

    Re: calling a javascript function inside a CODE BEHIND sub procedure

    There are several ways to add javascript in the codebehind. The most common technique in ASP.NET 1.x is using the RegisterStartupScript and RegisterClientScript property of the page.

    http://www.codeproject.com/KB/aspnet/Mayank_Gupta.aspx

    http://www.codeproject.com/KB/aspnet/ClientServer.aspx

    This has been deprecated in ASP.NET 2.0 and has since been replaced by the ClientScriptManager

    http://msdn2.microsoft.com/en-us/library/system.web.ui.clientscriptmanager_methods.aspx

     

    HTH

    devpinoy sig

    • Post Points: 20
  • 03-12-2008 7:05 PM In reply to

    Re: calling a javascript function inside a CODE BEHIND sub procedure

    How come this code works fine........ 

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    Dim hiScript As String = "alert(111);"

    If Not Page.ClientScript.IsClientScriptBlockRegistered("hi") Then

    Page.ClientScript.RegisterClientScriptBlock(Me.GetType, "hi", hiScript, True)

    End If

    End Sub

     

    And this dont......

    Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click

    Dim hiScript As String = "alert(111);"

    If Not Page.ClientScript.IsClientScriptBlockRegistered("hi") Then

    Page.ClientScript.RegisterClientScriptBlock(Me.GetType, "hi", hiScript, True)

    End If

    End Sub

    • Post Points: 35
  • 03-12-2008 10:45 PM In reply to

    • willydavidjr
    • Top 25 Contributor
    • Joined on 08-12-2006
    • Developer St., Programmers Homes, IT City
    • Posts 125
    • Points 6,605

    Re: calling a javascript function inside a CODE BEHIND sub procedure

    SuperNoob:

    How come this code works fine........ 

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    Dim hiScript As String = "alert(111);"

    If Not Page.ClientScript.IsClientScriptBlockRegistered("hi") Then

    Page.ClientScript.RegisterClientScriptBlock(Me.GetType, "hi", hiScript, True)

    End If

    End Sub

     

    And this dont......

    Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click

    Dim hiScript As String = "alert(111);"

    If Not Page.ClientScript.IsClientScriptBlockRegistered("hi") Then

    Page.ClientScript.RegisterClientScriptBlock(Me.GetType, "hi", hiScript, True)

    End If
    End Sub

    Kasi po nireregister mo ung script mo. Pero dapat ung script nasa code behind din. You will just declare it as a string.

     

    5th Year Bachelor of Technology Major in Information Technology Student (Batch 2006)-TUP Computer Engineering Technology Major in Software Engineering Technology Graduate(Batch 2002)- TUP Microsoft Club Blue Member: 060729001 MSDN Connection: PHL-037736-468
    • Post Points: 5
  • 03-13-2008 2:05 AM In reply to

    • JehPopoy
    • Top 150 Contributor
    • Joined on 02-25-2008
    • Posts 8
    • Points 215

    Re: calling a javascript function inside a CODE BEHIND sub procedure

    hi kuya,

    ung pangalawang  code mu nakalagay sa event handler ng linkbutton1.click, mareregister lng cya pag naclick na ung link button. Unlike ung una na nasa page_load event handler.

    Nga pla tsong, pdeng malamang kung anu ung gusto mung mangyari sa program? tnx.

     

    • Post Points: 20
  • 03-13-2008 3:25 AM In reply to

    Re: calling a javascript function inside a CODE BEHIND sub procedure

    wag niu i run sa isang file yan ha....

     bkt kht i click ayaw pa rin lumabas yung alert?

     

    gagawa sana ko ng time-in/time-out na module... ngayon dun sa submit btn... syempre madaming logical validation, kasama na dun yung kung login ba gagawin nya o mag lolog out na kc wala nmn pag pipilian e. 2 textbox lang at isang button ang nandun.

    ngayon naisip ko na kung  gusto nya mag time-in, pero actually nag time-in n sya nkalimutan lang nya, iisipin ng system na logout n yun. now to avoid that... gusto ko sana mag prompt ng isang confirmation dialog ng javascript para sa timeout procedure. tapos ang result nun ay gagamitin ng mga susunod na sub procedures kc nde nmn dun matatapos yung mga validations e kahit alam na ng system na mag lologout na tlga yung user.

    bsta ang idea....

    public sub button () handles CLICK

    vb codes for validations na nka class................

    then madadaanan yung validation na kung logout procedure n b, now before that meron sanang CONFIRMATION DIALOG ng JAVASCRIPT

    vbcodes for some more validations n nka class p din na nag va-vary depending on the value of the CONFIRMATION DIALOG.....

    tapos proceed kung timeIN, timeOUT, o CANCEL

    end sub

     

    yan sana na gets niu..

    hyyyy bt kc naimbento p tong .net na to e , masaya n nga sa classic e

    salamat po...

     

     

    • Post Points: 20
  • 03-13-2008 7:16 AM In reply to

    • JehPopoy
    • Top 150 Contributor
    • Joined on 02-25-2008
    • Posts 8
    • Points 215

    Re: calling a javascript function inside a CODE BEHIND sub procedure

    sori wrong post

     

     

    • Post Points: 5
Page 1 of 1 (8 items)