Solved

Adding jquery blocks __doPostback on aspx server generated objects

Posted on 2011-02-17
3
1,001 Views
Last Modified: 2012-05-11
Hi experts,

Hi have an aspx page with a repeater binded to a database:

<asp:Repeater runat="server" ID="repeaterMenu" DataSourceID="sdsApartats" OnItemDataBound="repeaterMenu_ItemDataBound" >
    <ItemTemplate>
        <tr id="trMenu">
            <td class="tdMenu">
                <asp:Panel ID="divMenu" runat="server" CssClass="menu" >
                    <asp:LinkButton ID="lbMenu" runat="server" CssClass="menu" OnClick="lbMenu_Command" CommandArgument=<%# Eval("idApartat") %>>
                        &nbsp; <%# Eval("titol").ToString().PadLeft(30,' ') %> &nbsp;
                    </asp:LinkButton>
                </asp:Panel>
            </td>
        </tr>
    </ItemTemplate>
</asp:Repeater>

Open in new window


A bit forward I need a jquery animation so I add a jquery reference in the header:

<script src="Scripts/jquery-1.4.1.js" />

Open in new window


Only with this reference to jquery in the header, every time I run the application the page renders OK, but it raises an error:

Microsoft jscript runtime error: object expected

Open in new window


with debugger stopped at:

__doPostBack('ctl00$repeaterMenu$ctl00$lbMenu','')

Open in new window


I supose jquery gets somehow confused with the "$" separator in the sender's ID.
I've googled and even ee-ed and found no clue.

Can someone put a little light on this. An answer will be fully appreciated.
0
Comment
Question by:Catalaziz
[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
3 Comments
 
LVL 16

Accepted Solution

by:
BurnieP earned 250 total points
ID: 34921887
Hi,

You might have some conflict with another javascript library in your project.  You can try setting the noConflict to JQuery after your JQuery reference :

<script src="Scripts/jquery-1.4.1.js" />
<script type="text/javascript">
  $.noConflict();
</script>
0
 

Author Comment

by:Catalaziz
ID: 34924379
Thanks BurnieP,

There is no other library javascript library in this project.
You can easily repeat this behaviour by:

1. Create a new web site in Visual Studio .net framework 3.5.
2. In the default.aspx webform add a sqldatasource (or any other database binding object)
3. Add a repeater that generates a linkbutton for each record in the datasource object.
4. Link the command event handler of each linkbutton generated. Or use the itemcommand of the repeater; it makes no difference.
5. Add a reference to jquery in the head section of the aspx code.
6. Add a simple jquery animation at the document.ready jquery event.

That's all. Page renders OK but if you click on any of the generated buttons, you'll get the error.

Adding $.noConflict() gets postback running again, but any other jquery function (that simple animation at the document.ready event) stops working.

If I remove the asp:repeater, then the jquery code works fine, but I need those asp:repeater generated linkbuttons
0
 

Author Closing Comment

by:Catalaziz
ID: 34924396
Sorry for this section in my last comment:

"Adding $.noConflict() gets postback running again, but any other jquery function (that simple animation at the document.ready event) stops working."

The animation wasn't working because of a bug in the code of the animation.

You nailed it BurnieP!
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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

733 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