Javascript do not return a proper value when used in a content page ASP.NET

grimstoner

New Member
I'm totally new to Javascript(Jquery) and still a beginner in ASP.NET.I have a contentpage that has a gridview gvUsers I made a code for the event RowDatabound that add an "id" in its markup for every rows. and its rows are clickable and can be selected through javascript in the contentpage page. \[code\] <script src="http://code.jquery.com/jquery-1.8.3.js" type="text/javascript"></script> <script type="text/javascript"> $(function() { $('#<%=gvUsers.ClientID%> tr[id]').click(function() { $('#<%=gvUsers.ClientID%> tr[id]').css({ "background-color": "White", "color": "Black" }); $(this).css({ "background-color": "Black", "color": "White" }); }); $('#<%=gvUsers.ClientID%> tr[id]').mouseover(function() { $(this).css({ cursor: "hand", cursor: "pointer" }); }); }); $(function() { var RowID = $('#hdnEmailID').val(); if (RowID != "0") { $('#<%=gvUsers.ClientID%> tr[id=' + RowID + ']').css({ "background- color": "Black", "color": "White" }); } $('#<%=gvUsers.ClientID%> tr[id]').click(function() { $('#<%=gvUsers.ClientID%> tr[id]').css({ "background-color": "White", "color": "Black" }); $(this).css({ "background-color": "Black", "color": "White" }); $('#hdnEmailID').val($(this).attr("id")); }); $('#<%=gvUsers.ClientID%> tr[id]').mouseover(function() { $(this).css({ cursor: "hand", cursor: "pointer" }); }); }); </script>\[/code\]In these scripts, they get the "id" property of the selected row and save it to hdnEmailID...\[code\]<INPUT id="hdnEmailID" type="hidden" value="http://stackoverflow.com/questions/13834105/0" runat="server" >\[/code\]To make the value hdnEmailID displayed in the page I made a code in inside a button click event that has a code like this..\[code\]Response.write(hdnEmailID.value);\[/code\]At first it works pretty fine and displays the "id" of the row that I clicked however after I used this code in a master-content pagesthe script returns 0. And it seems that when I click the button..The masterpage is reloaded and seems the script is reloading too thus returning the default 0I am not sure if this is really what happened since I'm a beginner in ASP.NET :)
 
Back
Top