Solved

return a value from javascript from vb.net web page

Posted on 2011-02-11
4
306 Views
Last Modified: 2012-05-11
I have a javascript that returns a value of true or false.  In my code behind in need to run the javascript and get a return value.  but when i try and use
if ClientScript.RegisterClientScriptBlock(Me.GetType(), "ClientScript", "checkCreditCard ('" & ddCardType.SelectedValue & "' , '" & txtCardNo.Text & "') ", True) then

I get message that this doesnt return a value.  Any ideas?

thank you
0
Comment
Question by:mgmhicks
[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
  • 2
4 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 34874290
in your dropdown/selectbox use : ddCardType

<asp:HiddenField runat="server" ID="HiddenField1" />
<asp:DropDownList runat="server" ID="ddCardType" onchange="document.getElementByid('<%= HiddenField1.ClientID %>').value = this.value;">

Open in new window


On the server side you will be able to read the value of the asp:HiddenField
0
 

Author Comment

by:mgmhicks
ID: 34874504
leakim971 getting this error

Microsoft JScript runtime error: Object doesn't support this property or method on the 2nd line you have me.  It highlights starting at "document ...
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34874617
0
 

Author Closing Comment

by:mgmhicks
ID: 34874860
I took a different approach.  I used the onchange event to call the function, then get the elements for ddcardtype and txtcardno, test the card and return value true or false back to hiddenfield.  So it was a combo of both suggestions that got me there.
thanks
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

734 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