0
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page 
{
    NurseCounter nc;
    protected void Page_Load(object sender, EventArgs e)
    {
        int id = int.Parse(Request.QueryString["counterid"]);
        int play = int.Parse(Request.QueryString["display"]);
        try
        {
            nc = new NurseCounter(id);
            Response.Write(nc.RenterCounter(play));
        }
        catch
        {
            Response.Write("Counter Error Id=" + Request.QueryString["counterid"]);
        }
    }
}

When i test in test.htm


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
</head>
<body>
<script type="text/javascript" src="http://localhost:4464/NurseCounter/Default.aspx?counterid=2&display=6"></script>
</body>
</html>

and , response dont display in test.htm

1 Answer 1

1

SO: Pass vars to JavaScript via the SRC attribute

*Edit: Updated to accomodate your comment.

If you'd like to display anything returned by a server side-script/page, you'd need to use AJAX. I would recommend using jQuery for that purpose. A simple example of using it after you've included it looks like this:

$.get("mypage.aspx", function(data){
  alert("Data Loaded: " + data);
});

Once you call this on your page, an alert dialogue box will appear with the output of your page contained in "data". Go through jQuery's tutorial section. Learn it, live it, love it! :)

Sign up to request clarification or add additional context in comments.

2 Comments

i would like to display text from default.aspx not parameter ?
Updated my answer as per your comment above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.