English 中文(简体)
An update panel, a postback and jQuery
原标题:

An update panel, a postback and jQuery. Sounds like a bad joke, but here s my situation.

I ve got two grids wrapped up in a MS update panel. The grids each have buttons in them that cause postback events to happen. under one grid is a div which is hidden by a jQuery function. And in one grid is a hyperlink which can cause that hidden div to show. Inside of the hidden div is a asp:button used for another postback.

Now is when I run into a problem. When I click either one of the buttons inside the grids, my div which is hidden by jQuery shows up. I don t want it to show up. In fact it should stay hidden until I call the method to make it show up. The hyperlink click event for the div does work, it s just that on a postback, the hidden div shows. Anyone know what could be causing this? Am I missing something on the postback or do I need more in the document.ready section of the jquery. Or is the MS ajax update panel screwing with things.

Here s a snippet of the jQuery to hide the div:

$(document).ready(function() {
   $("#actionDiv").hide();                 
});
最佳回答

$(document).ready() won t fire after an MS AJAX panel is updated. If you can set the css on actionDiv before it goes to the browser that would be better for that issue.

问题回答

$(document).ready(function() only gets called one time. You are doing a partial postback so you need to set the $("#actionDiv").hide(); each time.

<script language="javascript" type="text/javascript">
    function AfterPostBackInit() { $("#actionDiv").hide(); }

    // Run AfterPostBackInit() when the page loads and after every post-back.
    Sys.Application.add_load(AfterPostBackInit);
</script>




相关问题
Prevent Postback when user clicks browser s back button

I have a web page that sends email to multiple users (online distribution list). After the submit button is clicked and the email is sent, a status page is shown listing how many emails were sent, ...

An update panel, a postback and jQuery

An update panel, a postback and jQuery. Sounds like a bad joke, but here s my situation. I ve got two grids wrapped up in a MS update panel. The grids each have buttons in them that cause postback ...

ASP.NET - Control Events Not Firing Inside Repeater

This is a absurdly common issue and having exhausted all of the obvious solutions, I m hoping SO can offer me some input... I have a UserControl inside a page which contains a repeater housing several ...

How do I make a Textbox Postback on KeyUp?

I have a Textbox that changes the content of a dropdown in the OnTextChanged event. This event seems to fire when the textbox loses focus. How do I make this happen on the keypress or keyup event? ...

Postback after JQuery Dialog box closes causes js error in IE

I am creating JQuery dialog boxes and need the close functionality to cause a postback to the parent form (so that data changed in the popup form displays immediately on the parent screen). I have ...

How Do I Get a Dynamic Control s Value after Postback?

I have a listview that adds controls in the ItemDataBound Event. When the postback occurs, I cannot find the new controls. After a bit of research, I found that ASP .NET needs these controls created ...

ASP.Net s auto-postback. What happens when its too slow?

I am making a web application. I have gotten a weird error with update panels. Ok, so say you have two update panels and each update panel has a textbox in it. Both of these textboxes are auto-...

热门标签