views:

436

answers:

1

Hi!

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?

A: 

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, then add the query:

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

InfinitiesLoop
thanks I removed it.
Hossein Margani

related questions