Solved

Jquery not work on PostBack Page

Posted on 2009-04-14
3
1,037 Views
Last Modified: 2013-12-17
Hello,

I have a page where run a Jquery, but when she made a PostBack simply stops working, any idea?

See code below:
function closeCheckbox() {
    $("span").each(function() { if ($(this).attr("child")) { $(this).hide(); } });
}

Open in new window

0
Comment
Question by:alexandremattar
[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
3 Comments
 
LVL 14

Expert Comment

by:GiftsonDJohn
ID: 24145317
Are you using UpdatePanel and doing asynchronous post back?
0
 
LVL 3

Expert Comment

by:OmerFarukZ
ID: 24145484
where is the jquery script code imlemented? please paste your aspx source code
0
 
LVL 1

Accepted Solution

by:
alexandremattar earned 0 total points
ID: 24147331
Here is the aspx code.

Yesterday i solved the problem, the atributtes of checkboxlist be lost in postback. But this is not the best solution.
I will also post the Codebehind to see if we find better solution
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="ThumbGridView.WebForm1" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
 
    <script src="jquery-1.3.2.js" type="text/javascript"></script>
 
</head>
<body>
    <form id="form1" runat="server">
    <div>
    </div>
    <div id="check">
        <asp:CheckBoxList ID="CheckBoxList1" runat="server">
        </asp:CheckBoxList>
    </div>
    <asp:Button ID="Button1" runat="server" Text="Button" />
    </form>
    <asp:Literal ID="Literal1" runat="server">
 
         <script language="javascript" type="text/javascript">
 
 
             $(document).ready(function() {
                 $("span").each(function() {
                     if ($(this).attr("filho")) {
                         $(this).hide();
                     }
                 });
                 $("#check :checkbox").each(function() {
                     current = $(this).parent().attr("pai");
 
                     if ($(this).is(':checked')) {
                         $("span").each(function() {
                             if ($(this).attr("filho") == current) {
                                 $(this).show();
                             }
                         });
                     }
 
                 });
             });
             
             $("#check :checkbox").click(function() {
                 $("span").each(function() {
                     if ($(this).attr("filho")) {
                         $(this).hide();
                     }
                 });
                 $("#check :checkbox").each(function() {
                     current = $(this).parent().attr("pai");
 
                     if ($(this).is(':checked')) {
                         $("span").each(function() {
                             if ($(this).attr("filho") == current) {
                                 $(this).show();
                             }
                         });
                     }
 
                 });
             });
       
    </script> </asp:Literal>
</body>
</html>

Open in new window

codeBehind.txt
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
asp.net figure out error 3 45
c#, case, if 4 37
What are MicroServices? 4 67
ASP.NET generate check digit for ITF-14 and EAN-13 barcodes 4 33
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

732 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