How can I pass a variable?

Posted on 2005-03-14
Medium Priority
Last Modified: 2012-05-05
This is the Java Script :
function getconfirm(str)
var retval=null;
var href="Form.aspx"+str;
This is the VB code:
Private Sub cmdPrint_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdPrint.Init
   Dim cmd As System.Web.UI.WebControls.Button
   Dim valuetopass as integer = Me.Label1.Text
1.-   cmd.Attributes.Add("onclick","getconfirm('This is the value to pass');")     "WORKS O.K"
2.-   cmd.Attributes.Add("onclick","getconfirm(valuetopass);")     "CAUSES AN ERROR"
When I use (1.) Statement Form.aspx shows the value O.K, but using (2.-) I have an error, can anybody show me how to pass a value correctly?
Question by:NeGueSa
LVL 11

Expert Comment

ID: 13538374
Hi there,

what error do message do you get?


Author Comment

ID: 13538395
The label shows "Undefined"

Accepted Solution

RogerSTHLM earned 1000 total points
ID: 13542585
You need to build the js command as a string

2.-   cmd.Attributes.Add("onclick","getconfirm(" + valuetopass + ");")
or, if you pass a string or date
2.-   cmd.Attributes.Add("onclick","getconfirm('" + valuetopass + "');")        

Hope it helps

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
Hi, this video explains a free download that you can incorporate into your Access databases, or use stand-alone for contact management. Contacts -- Names, Addresses, Phone Numbers, eMail Addresses, Websites, Lists, Projects, Notes, Attachments…
Suggested Courses
Course of the Month5 days, 20 hours left to enroll

588 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question