Solved

return a value from javascript from vb.net web page

Posted on 2011-02-11
4
299 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
  • 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Library to convert HTML to PDF. 8 44
JavaScript Scope issue 4 19
Cordova Camera plugin fails 2 19
Adjust the position 3 12
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

706 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now