Exforsys
+ Reply to Thread
Results 1 to 5 of 5

Call javascript function in C#

This is a discussion on Call javascript function in C# within the Microsoft .NET forums, part of the Programming Talk category; How can i "Call JavaScript function in C# and C# function or objects id JavaScript"...

  1. #1
    Limca is offline Junior Member Array
    Join Date
    Apr 2006
    Answers
    21

    Question Call javascript function in C#

    How can i "Call JavaScript function in C# and C# function or objects id JavaScript"


  2. #2
    Adrian is offline Senior Member Array
    Join Date
    Apr 2006
    Answers
    124
    you can define on click event, then call java script function...


  3. #3
    Raman is offline Junior Member Array
    Join Date
    Feb 2006
    Answers
    15
    Calling Javascript method from Code behindYou can call Javascript functions as a script registered on the codebehind itself but i m not sure about your requirement. Dot net providesPage.RegisterStartupScript("key","value") method.Here, key is the name you want to give the script eg. "PageClose"value is the string .stringBuilder str = new StringBuilder()str.Append("");str.Append("window.close();");str.Append("")Then use this in the event handler you want to execute the scriptPage.RegisterStartUp("PageClose",str.ToString());This would place the javascript before the closing tag of the page thats renderedPage.ClientScriptBlock("PageClose",str.ToString());This would place the JS function after the opening
    tag of the page thats renderedDepeding on your need, you can choose the method to included the script in the page when rendered at the client.Hope, this clears your query.


  4. #4
    Raman is offline Junior Member Array
    Join Date
    Feb 2006
    Answers
    15
    any more other ways


  5. #5
    Charith is offline Junior Member Array
    Join Date
    Jan 2006
    Answers
    11
    there are basically 3 methods..

    the very basic is to write ur java script into response.write()..

    if you want to attachthe script with a web control..then in page load function controlID.attributes.add("Event","script function")

    or u can try
    page.registerstartupscript()

    hope it'll help u out..

    All the best


    •    Sponsored Ads



Latest Article

Network Security Risk Assessment and Measurement

Read More...