javascript and asp.net


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 15 of 15

Thread: javascript and asp.net

  1. #1
    Join Date
    Sep 2005
    Posts
    10

    javascript and asp.net

    I have a program which runs a lot of batch files so I have built a progress bar by javascript which shows the progress. After I run every batch file I call the javascxript function and the function increases the bar by 1 point. This works in asp so I tried to convert it to asp.net I do something like this:
    -------------------------------------------------------------
    mystring="<script language='javascript'>imgLoaded();" & chr(60) &"/script>"
    run the first batch
    RegisterStartupScript("JString1", myString.ToString())
    run the second batch
    RegisterStartupScript("JString2", myString.ToString())

    and so on.........

    --------------------------------------------------------------
    when I do this all the batches are run and then the javascript function is called.Thats is not what I want...I want to run the batch and then call the javascript function.
    Do you know how I can do this?
    thanks

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Sep 2005
    Posts
    10

    thanks

    thanks.... I am going to look into that

  4. #4
    Join Date
    Sep 2005
    Posts
    10

    any otyher way

    So there is no way of calling javascript functions immediately when the .net code is running.why does javascript function call has to wait till the .net code is over?
    cenk

  5. #5
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Because JavaScript code runs in the user's browser, and ASP.NET code runs on the server. There's no way for code on the server to execute code in the user's browser.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  6. #6
    Join Date
    Sep 2005
    Posts
    10

    but...

    but I can do what I want with asp...

    run asp code
    call the javascript function
    run asp code
    call the javascript function
    and so on........

    why can not I do it with asp.net?

  7. #7
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    I don't see how that can work, even in ASP. Can you post a simple page that demonstrates this technique?
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  8. #8
    Join Date
    Sep 2005
    Posts
    10

    example page

    ok here is an example page:
    http://www.imlab.psu.edu/aspnet/forest/progress.asp
    you cann see the javascript contents of this page and the only asp content of this page is :

    <%
    Response.buffer = false
    Server.ScriptTimeout = 400

    for g=1 to 648
    Response.write "<script>imgLoaded();</script>"
    Next
    %>

    and this works!!!or am I missing something?

  9. #9
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    The difference is that ASP code is interpreted script, whereas ASP.NET is compiled code.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  10. #10
    Join Date
    Sep 2005
    Posts
    10

    <% tag

    when I use the "<%" in asp.net then I call the functions...Does that mean that whatever is in "<%" tags in asp.net is being interpreted but not being compiled?
    If it s then I should minimize using the "<%" tags right?

  11. #11
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    No, all server-side code in ASP.NET is compiled.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  12. #12
    Join Date
    Sep 2005
    Posts
    10
    so how come the code works when I put the
    Response.write ("<script language='javascript'>imgLoaded();</script>")
    line in the "<%" blocks
    and it does not work when I put it in the "sub Page_Load" method?

  13. #13
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    If it works when you put the code in <% %> blocks, then why are you asking for help? ;-)
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  14. #14
    Join Date
    Sep 2005
    Posts
    10

    why?

    because I am wandering why it works that way and not the other way?I thought I was doing something wrong.....because this should not really work....net is server side and compiled and javascript is client side so how is it possible that they work together?
    also I might have problems with using codebehind if I use "<%" tags..am I not right?

  15. #15
    Join Date
    Jun 2004
    Location
    Pakistan
    Posts
    292
    When you do response.write, it is writing to your browser. so when your page is loaded it every thing in WRITE is put at the top of the file. so they are not exactly work together...it is just that you are writing your exact browser code/script at the server.

    In the ASP sample, ASP and JavaScript are not working together but ASP code is creating the javascript which is then called over and over by the browser. In other words, if you had a lot of code before the response.write..it would still finish everything on the server and then write the script. Consequently you will see the image bar but only after every thing is done.
    new to programming but getting ther

Similar Threads

  1. Javascript with ASP.NET
    By Raffee in forum ASP.NET
    Replies: 1
    Last Post: 06-30-2005, 08:48 AM
  2. Free ASP.NET Web Matrix Design/Editor Tool Released
    By ASPSmith Training in forum dotnet.announcements
    Replies: 0
    Last Post: 06-18-2002, 04:39 AM
  3. Javascript and ASP.Net....Perfect Together???
    By KraKheD in forum ASP.NET
    Replies: 1
    Last Post: 11-06-2001, 11:51 AM
  4. Replies: 1
    Last Post: 11-05-2001, 08:54 PM
  5. Replies: 4
    Last Post: 10-11-2001, 06:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center