1

I use ScriptManager in my ASP.NET page, and want to add a ScriptReference which is a page request like this:

var id = 10;
tsm.CompositeScript.Scripts.Add(new ScriptReference("~/Response.aspx?action=test&id=" + id));

but it raises an error:

'~/Response.aspx?action=test&id=10' is not a valid virtual path.

I should add this script dynamically, what should I do?

1 Answer 1

3

You're trying to mix a virtual path with querystring parameters, I think the underlying ASP.NET method that resolves the "~" part expects the string to be a pure virtual path, not a url. So, map it as a pure path first, and then add the query:

 tsm.CompositeScript.Scripts.Add(new ScriptReference(ResolveClientUrl("~/Response.aspx") + "?action=test&id=" + id));
Sign up to request clarification or add additional context in comments.

Comments

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.