0

Any idea why my function isn't getting injected into the web page? I'm pretty sure I've done this before and it worked, but when I launch from VS and look at the page I don't see it anywhere.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string deviceID = Guid.NewGuid().ToString();
        string deviceFunction = "function GetDeviceID() { return '" + deviceID + "'; }";

        ClientScript.RegisterClientScriptBlock(GetType(), "DeviceID", deviceFunction, true);

    }
}

1 Answer 1

1

I was able to find the answer to this. Turns out you MUST have a <from> tag and have runat="server" in order for this to work.

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

1 Comment

A <form> tag? I believe all asp.net controls require the form tag in order to work (FYI to other searchers).

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.