Hello mrwillis,
I'd be curious to see your javascript code and what you are trying to do. Both out of curiosity and maybe to suggest a different way to solve your problem.
Thing is, you can't "pass" variables from codebehind to clientside code.
http://img265.imageshack.us/i/imagewzyv.jpg/For general information you could look into stuff like:
1. Code Blocks:
C#:
protected string TempString="Test string";
Javascript:
var temp="<%=TempString%>";
Of course this only works if you know your manufacturing number when the page loads. If you try this out, have a look at the Page Source, there is no variable, just some text...
2. You can pass the whole Javascript function:
Response.Write("<script>alert('manufacturing number')</script>");
This is less bad than it looks like.
3. You can sneak in some value into a hidden field on the aspx page:
C#:
manufacturingnumber.value = "1";
Javascript:
<input type=hidden id=manufacturingnumber runat=server id=manufacturingnumber>
People on the internet recommend that all the time.
4. A complicated solution would be JSON/Webservices
jQuery(function ($) {
$("#Button1").click(function () {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "WebService1.asmx/HelloWorld",
data: "{a:'" + "World" + "'}",
dataType: "json",
success: activateFunctionsCallback
});
});
});
function activateFunctionsCallback(data) {
alert(data["d"]);
}
C#:
[WebService(Namespace = "http://xtempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// Um das Aufrufen dieses Webdiensts aus einem Skript mit ASP.NET AJAX zuzulassen, heben Sie die Auskommentierung der folgenden Zeile auf.
[System.Web.Script.Services.ScriptService]
public class WebService1 : System.Web.Services.WebService
{
[WebMethod(EnableSession = true)]
[ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)]
public string HelloWorld(string a)
{
return "Hello " + a;
}
}
With this you can actually take user input, do something with it server-side, like look up a manufacturing number, and return it to a script client side. If you want to go that route you can copy+paste most of the code above, play around with it, pick up a bit "jQuery", check out "Webservices" and realize that this is all asynchronous and a bit slow, so that it's just a workaround as well.
But do tell us more about what code you have and what you are trying to do!