Java script in asp.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • suryany72
    New Member
    • Aug 2007
    • 1

    Java script in asp.net

    I have two questions to ask in this forum
    1) How to include java script file in .aspx file?
    2) I wrote a following class with a function called JavaScriptFunct ion. The issue I am facing is when I am using this function to display message, the background of web page was white ie no style sheets were applied to .aspx page and no others controls were displayed. When I click on “ok”, I am coming back to same page.

    The code for the JavaScriptFunct ion is as follows
    public static void JavaScriptFunct ion(string alertmessage)
    {

    System.Web.Http Context.Current .Response.Write ("<script language='javas cript'>");
    System.Web.Http Context.Current .Response.Write ("alert('" + alertmessage + "')");
    System.Web.Http Context.Current .Response.Write ("</SCRIPT>");
    }
    .
    Thanks in advance
    surya
  • kmithu
    New Member
    • Jun 2007
    • 11

    #2
    You dont have to include any java script file in this case.....the code you have written i s correct

    Comment

    • viswarajan
      New Member
      • Jun 2007
      • 10

      #3
      Hello here is the simple way ...

      in the Page load of your code behind ..

      btnID.Attribute s.Add("onclick" , "doClick('" + alertmessage +"')");

      in the script block of your .aspx page call the method as

      <script language="javas cript" type="text/javascript">
      function doClick(mess)
      {
      alert(mess);
      }
      <script>


      Thanks
      Natarajan.v
      www.vezoom.com

      Comment

      Working...