Solved

return a value from javascript from vb.net web page

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

828 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