Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling Jquery from asp.net Code Behind. 1

Status
Not open for further replies.

Dashley

Programmer
Dec 5, 2002
925
US
The following Jquery & HTML produces a barcode128 and all works fine.

HTML:
</head>
    <script src="[URL unfurl="true"]http://cdnjs.cloudflare.com/ajax/libs/jquery/1.7.1/jquery.min.js"[/URL] type="text/javascript"></script>
	<script src="scripts/CODE128.js"></script>
	<script src="scripts/JsBarcode.js"></script>
	
       <script>
	     $(document).ready(function () {
	        $("#barcode").JsBarcode("testdata", { width: 1, height: 50 });
	        });
       </script>
<body>
    <form id="form1" runat="server">
    <div>
            <asp:Image runat="server" ID="barcode" />
    </div>
    </form>
</body>

I'm trying to call this JQuery Script from a code behind page in asp.net from a page load event as I want to pass a value into the bar code

I've tried several variations of the code below with no success. Any help will be greatly appreciated. First time using Jquery and i don't do a lot of JS. :(

Code:
 ScriptManager.RegisterStartupScript(Me.Page, Me.GetType(), "javascript", " JsBarcode(#barcode, 'Newvalue',  { width: 1, height: 50 })", True)
 
Try
Code:
   Page.RegisterStartupScript(Me.GetType(),"javascript","$('#barcode').JsBarcode('testdata', { width: 1, height: 50 });", True )

Also, check your syntax to the JsBarcode call. The width and height may need to be strings.
 
OK Thanks JB. I'll give it a whirl here in a bit. I'll let you know the outcome.
 
JB Hi,


Had to tweak it just a bit but again your my hero :)

Thank you very much.

ClientScript.RegisterStartupScript(Me.GetType(), "javascript", "$('#barcode').JsBarcode('" & mynumber & "', { width: 1, height: 50 });", True)



Take Care

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top