Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Mar 15, 2011 12:19 PM by asteranup
Member
106 Points
124 Posts
Mar 13, 2011 08:21 PM|LINK
I have a web page with the following button and text field declared.
<input type="button" id="GetValue" value ="Get Value"/>
<input type="text" ID="TextBox1" runat
="server"/>
On Page_Load I set a value of "XXX" into TextBox1.I have the following script declared with a function for onclick.
() { $('#GetValue').button().onclick = function () { alert("Running the last action"); g_ListVal = ($('#TextBox1
).val()); }
I toggled a break point in the function but when I click the button nothing happens.
What am I doing wrong?
Star
11721 Points
1859 Posts
Mar 13, 2011 08:39 PM|LINK
Your jQuery is wrong:
$(document).ready(function () { $('#GetValue').click(function() { alert("Running the last action"); g_ListVal = $('#TextBox1').val(); }); });
Contributor
4035 Points
1079 Posts
Mar 13, 2011 08:41 PM|LINK
as per your query, I assume you are trying to debug your javascript funtion.
Clientside debugging works only in Visual Studio Proffecional, Pre and unltimate.
Please see below link to know how to enable client script debugging ( if you've not enabled yet).
MSDN - How to: Enable and Start Script Debugging from Internet Explorer
MSDN - Client-Side Script Debugging
Mar 13, 2011 08:43 PM|LINK
Your jQuery is wrong if you mean putting a break point in the JavaScript function:
Mar 14, 2011 04:41 AM|LINK
Youn said the jquery was wrong but whatn exactly is mwrong?
Mar 14, 2011 04:44 AM|LINK
All-Star
30184 Points
4906 Posts
Mar 14, 2011 04:56 AM|LINK
Hi,
Check this-
$(document).ready(function() { $("input[type=button][id*=GetValue").click(function(){ alert("Running the last action"); g_ListVal = $("input[type=text][id*=TextBox1]").val(); }); });
Mar 14, 2011 11:43 AM|LINK
I tried this code but the alert is still not shown.
Mar 14, 2011 11:58 AM|LINK
This should be working fine. You may be missing something-
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { $("input[type=button][id*=GetValue").click(function() { alert("Running the last action"); g_ListVal = $("input[type=text][id*=TextBox1]").val(); }); }); </script> </head> <body> <form id="form1" runat="server"> <input type="button" id="GetValue" value="Get Value" /> <input type="text" id="TextBox1" runat="server" /> </form> </body> </html>
16826 Points
3684 Posts
Mar 14, 2011 11:59 AM|LINK
The code provided by Anup should work, could you post your updated code?
harrytu@clea...
Member
106 Points
124 Posts
button onclick
Mar 13, 2011 08:21 PM|LINK
I have a web page with the following button and text field declared.
<input type="button" id="GetValue" value ="Get Value"/>
<input type="text" ID="TextBox1" runat
="server"/>
On Page_Load I set a value of "XXX" into TextBox1.I have the following script declared with a function for onclick.
<script type="text/javascript">$(document).ready(function
() {
$('#GetValue').button().onclick = function () {
alert("Running the last action");
g_ListVal = ($('#TextBox1
).val());
}
I toggled a break point in the function but when I click the button nothing happens.
What am I doing wrong?
whighfield
Star
11721 Points
1859 Posts
Re: button onclick
Mar 13, 2011 08:39 PM|LINK
Your jQuery is wrong:
$(document).ready(function () { $('#GetValue').click(function() { alert("Running the last action"); g_ListVal = $('#TextBox1').val(); }); });Blog | I need more space:DropBox Referral
duttavr
Contributor
4035 Points
1079 Posts
Re: button onclick
Mar 13, 2011 08:41 PM|LINK
as per your query, I assume you are trying to debug your javascript funtion.
Clientside debugging works only in Visual Studio Proffecional, Pre and unltimate.
Please see below link to know how to enable client script debugging ( if you've not enabled yet).
MSDN - How to: Enable and Start Script Debugging from Internet Explorer
MSDN - Client-Side Script Debugging
Please Mark as Answer, if it answers you, also correct me if I'm wrong.
whighfield
Star
11721 Points
1859 Posts
Re: button onclick
Mar 13, 2011 08:43 PM|LINK
Your jQuery is wrong if you mean putting a break point in the JavaScript function:
$(document).ready(function () { $('#GetValue').click(function() { alert("Running the last action"); g_ListVal = $('#TextBox1').val(); }); });Blog | I need more space:DropBox Referral
harrytu@clea...
Member
106 Points
124 Posts
Re: button onclick
Mar 14, 2011 04:41 AM|LINK
Youn said the jquery was wrong but whatn exactly is mwrong?
whighfield
Star
11721 Points
1859 Posts
Re: button onclick
Mar 14, 2011 04:44 AM|LINK
Blog | I need more space:DropBox Referral
asteranup
All-Star
30184 Points
4906 Posts
Re: button onclick
Mar 14, 2011 04:56 AM|LINK
Hi,
Check this-
$(document).ready(function() { $("input[type=button][id*=GetValue").click(function(){ alert("Running the last action"); g_ListVal = $("input[type=text][id*=TextBox1]").val(); }); });Anup Das Gupta
Mark as Answer if you feel so. Visit My Blog
harrytu@clea...
Member
106 Points
124 Posts
Re: button onclick
Mar 14, 2011 11:43 AM|LINK
I tried this code but the alert is still not shown.
asteranup
All-Star
30184 Points
4906 Posts
Re: button onclick
Mar 14, 2011 11:58 AM|LINK
Hi,
This should be working fine. You may be missing something-
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { $("input[type=button][id*=GetValue").click(function() { alert("Running the last action"); g_ListVal = $("input[type=text][id*=TextBox1]").val(); }); }); </script> </head> <body> <form id="form1" runat="server"> <input type="button" id="GetValue" value="Get Value" /> <input type="text" id="TextBox1" runat="server" /> </form> </body> </html>Anup Das Gupta
Mark as Answer if you feel so. Visit My Blog
nilsan
All-Star
16826 Points
3684 Posts
Re: button onclick
Mar 14, 2011 11:59 AM|LINK
The code provided by Anup should work, could you post your updated code?