Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Javascrip And asp.Net vb help needed

Posted on 2016-09-22
2
Medium Priority
?
120 Views
Last Modified: 2016-09-23
This method adds a javascript method to marks text box onkeydown, that javascript method takes the rowindex as argument. This code is being converted from C#. The method works fine using C#, but I got a “Conversion from string "javascript: DoPostBackWithRowInd" to type 'Double' is not valid “message when using the VB code below. Please help!


<script type="text/javascript" language="javascript">

        function DoPostBackWithRowIndex(rowIndex) {

            if (document.getElementById('<%=HdnSelectedRowIndex.ClientID%>') != null) {

                document.getElementById('<%=HdnSelectedRowIndex.ClientID%>').value = rowIndex;

            }

            return true;

        }

    </script>

 

'Event to handle the Users Grid DataBound Event
'This method adds a javascript method to marks text box onkeydown, that javascript method takes the rowindex as argument.

    Protected Sub GvUsersRowDataBound(ByVal sender As Object, ByVal eventArgs As GridViewRowEventArgs)

        If (eventArgs.Row.RowType = DataControlRowType.DataRow) Then

            Dim TxtMarks As TextBox = CType(eventArgs.Row.FindControl("TxtMarks"), TextBox)

            TxtMarks.Attributes.Add("onkeydown", "javascript:return DoPostBackWithRowIndex('" + eventArgs.Row.RowIndex + "');")

        End If

 

    End Sub
0
Comment
Question by:HPH Y
[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 Comments
 
LVL 12

Accepted Solution

by:
Ramkisan Jagtap earned 2000 total points
ID: 41810780
remove ' '  from following statement

TxtMarks.Attributes.Add("onkeydown", "javascript:return DoPostBackWithRowIndex(" + eventArgs.Row.RowIndex + ");")

Open in new window

1
 

Author Closing Comment

by:HPH Y
ID: 41812850
Hi Ramkisan, Thanks for helping me. Your answer is very helpful because it eliminated the error and I was able to debug the problem further. I eventually also needed  to substitute the two + sign to & sign in order to pass the javascript function properly. Again, your help is truly appreciated!!!! :)
0

Featured Post

Independent Software Vendors: 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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…

688 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