INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Calling Jquery from asp.net Code Behind.

Calling Jquery from asp.net Code Behind.

(OP)
The following Jquery & HTML produces a barcode128 and all works fine.

CODE --> html

</head>
    <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.7.1/jquery.min.js" 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 --> asp.net

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

RE: Calling Jquery from asp.net Code Behind.

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.

RE: Calling Jquery from asp.net Code Behind.

(OP)
OK Thanks JB. I'll give it a whirl here in a bit. I'll let you know the outcome.

RE: Calling Jquery from asp.net Code Behind.

(OP)
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

RE: Calling Jquery from asp.net Code Behind.

Cool, glad you got it working !!!!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close