Solved

return a value from javascript from vb.net web page

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

895 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

14 Experts available now in Live!

Get 1:1 Help Now