?
Solved

How can I pass a variable?

Posted on 2005-03-14
3
Medium Priority
?
214 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

777 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