?
Solved

How can I pass a variable?

Posted on 2005-03-14
3
Medium Priority
?
224 Views
Last Modified: 2012-05-05
This is the Java Script :
<script>
<!--
function getconfirm(str)
{
var retval=null;
var href="Form.aspx"+str;
retval=window.showModalDialog(href,'0',dialogWidth:450px;dialogHeight:700px;help:no;maximize:no;minimize:no)
}
//-->
</script>
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"
EndSub
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?
0
Comment
Question by:NeGueSa
3 Comments
 
LVL 11

Expert Comment

by:Babycorn-Starfish
ID: 13538374
Hi there,

what error do message do you get?

BCS
0
 

Author Comment

by:NeGueSa
ID: 13538395
The label shows "Undefined"
0
 
LVL 5

Accepted Solution

by:
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
Roger
0

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