On Updatepanel update, everything outside the updatepanel disappears - asp.net

Apologies for such a broad, sweeping question, but I can't really give specific code examples because as far as I can tell from research this problem is unique to the particular page I'm working on and if I knew what to do to replicate it then I'd most likely be able to fix it.
I have an asp.net vb (v3.5 using the ajaxcontroltoolkit v4) page essentially binding some straight forward SQL database data to a gridview.
The gridview's in an update panel and whenever I do anything that causes a postback inside the update panel, everything outside the update panel vanishes. The update panel IS updating correclty.
There's no conditional updating, just an 'out of the box' update panel.
All other ajax functionality is working correctly, such as filtered textbox extenders and validation with callout extenders, so I don't think it's a basic script reference error.
I'm making use of javascript and jquery to modify controls on the fly that are within the updatepanel.
It was a standalone page for development but for testing this problem I put it into a contentplaceholder on a masterpage. Now on updating, everything else in the contentplaceholder disappears, leaving the masterpages header etc present.
If you haven't come across this particular problem before, can you think of how I could go about debugging it?
If you have any ideas at all, it might be enough to set me down the right path.
Many thanks.

Thanks for taking the time to make suggestions Mt. Schneiders.
In the end...haha wow, embarrassing... I've been doing this for the best part of 6 years now and I was closing my updatepanel before closing a div that started above the panel.
Simple fix. Yay! Thanks again.

Related

Update Panel inside of a repeater

I have a repeater that houses a gridview. That gridview needs to be editable, and to make for a more fluid experience, I have the gridview wrapped with an update panel. There are n number of update panels on the page based on this. Everything is working perfectly fine, but I'm asking because I'm afraid of problems that may arise, such as postback size. Is this the best way to do this? Are there any pitfalls I'm not seeing?
You have an eligible concern.
First thing to know if that UpdatePanel post the whole page to the server, always, even including whole ViewState content. Nothing you can do about it, just make sure you acknowledge that. So if your page is very large and you notice significant lags in how the app works, you might want to consider a different approach, perhaps with manual async calls, or something like that.
Second thing immediately follows - whenever an UpdatePanel does a postback, server does the full page life cycle, and then just a part inside the UpdatePanel is updated on the page. Again, nothing you can or should do, this is just how UpdatePanel works. People are sometimes surprised by that fact while debugging, so it was worth mentioning.
Third thing is specific for your case, cause you have multiple UpdatePanels on the page. By default if one of them does a postback, all other panels do a postback as well, and consequently they all are updated. Maybe this is a desired behavior, maybe not. If not, you can set UpdateMode property of each UpdatePanel to Conditional, and they will be update only GridView inside triggers an update. More on this here.
These and much more other details on UpdatePanels, can be found in this article.

Ajax in existing asp .net project

I have a web page devoloped in visual studio 2008.
I have 4 dropdowns and a repeater in the page.based on the selection(search criteria) from the dropdowns the repeater value will change.
and one dropdown selection will bind values to the other dropdown also.
Since the page is causing a lot of postback we decided to implement ajax here.
I am yet to learn ajax.
Can anyone tell what is the best way to do this .which ajax control replace dropdowns?
i have already server side code written on all dropdowns.
Please give me a good solution which i can implement in less time and reuse my code.
One more update: i have a master page used in the project.
I am using update panel of ajax which does not work if i use master page.
(That means all the dropdown controls and repeater i put it in update panel.But still page postback occurs.)
In a normal page(without master page) it works? why is this happening?
Thanks
SNA
You are able to use UpdatePanel and place dropdowns inside it.
Your solution will depend on the AJAX framework you choose, but here are cascading dropdown examples in ASP.NET AJAX and jQuery
If your main reason for using AJAX is to remove the number of postbacks you are getting, then I would recommend against using Microsoft's built in solution, e.g updatepanels.
The learning curve will be higher but learn to use jQuery, maybe with a little help from jTemplate to help you build your drop downs on the page.
Using updatepanels will not reduce your postbacks as behind the scenes asp.net is doing a full page life-cycle, sending all content back to your client but only updating the update panel. jQuery will be far more efficient. (and the reason I use it!!)
Update
If you don't believe me, see... Why Update Panels are dangerous
Update #2
If you don't want to go the whole way of learning Ajax just yet (although I'd recommend it) you could always pre-load your page with all the possible drop down combinations and then swap them using javascript / javascript + jQuery.
Here is one example of how you may do it -- use jQuery for dependent drop down combos
Using this method you are more likely to be able to save the code you've already written to work out the drop down options.

javascript conflicts UpdatePanel

I'm using a ReportViewer control which often runs into problems with the javascript associated with UpdatePanels in ASP.NET. I've created a second page which is very simple, no Update Panels. What's the best way to link the two pages? An iframe sounds bad. However, having to run a report, then be returned a link to the results also sounds bad. Sending the user to the simple display won't work in this case. Any suggestions, am I seeing things wrong here?
What I would do is rewrite the page that uses an update panel such that it uses straight javascript web method calls. This would remove the need for the reportviewer control to be on a seperate page because you would no longer need an update panel.

Registering a dynamic javascript after an UpdatePanel's update

I have a page with a dynamicly created javascript (the script is pretty static really, but the value of its variables are filled based on user input).
The result and the controls to take user input is inside an UpdatePanel which updates itself on certain user intputs. Some of these userinputs cause changes in the variables i spoke of earlier so i need to register a new javascript.
The problem ofcourse is that only the updatepanel gets updated and the scripts are registred outside the update panel so no new scripts are added.
What do you think would be best practice now? I could solve this by letting this script (and variables) live inside the updatepanel or i could make sure the page is fully reloaded when the need for posting a new javascript arises? The ScriptManager that i already have on the page might be able to help me with this...
So i'm looking for someone who either had similar problems and solved them in a nice way, or just someone with some bright ideas :)
Have a look at ScriptManager.RegisterClientScriptBlock.
I've had better luck with ScriptManager.RegisterStartupScript than I did with ScriptManager.RegisterClientScriptBlock. You might give that a shot.
Why not just put the variables inside the update panel, or have the JavaScript get the values through the DOM?

Telerik RadComboBox in a RadGrid Client Side Validation

I'm using the Telerik ASP.net control suite (2008 Q3 I believe, can't upgrade yet). I've got a radcombobox in a Radgrid control (in a GridTemplateColumn's Edit template). If functions ok, but I've got some client side validation on other controls on the grid (that appear to be working without errors). For some reason after the client side validation happens, the combo box stops functioning. No visible js errors, the thing just dies.
Anyone seen this and have fix? Google has failed me.
Thanks for your help.
Ok, I solved it. Very cludgy work around.
First, I've got a panel outside of the multiviewpanel that holds my grid with another similar Radcombobox that also died on validation. I started thinking, what if I did some sort of post back, would that fix things for some reason? So in my grid I added a custom validator that validates the RadComboBox in my grid. It calls a javascript validation method like so...
function valCOMBO(o, a) {
a.IsValid = true;
setTimeout(Res, 500);
}
function Res() { __doPostBack("<%=OPCOCombo.UniqueID %>");}
Note, since this field isn't required to be filled in by the user, I always return is valid is true. Here is where the quasi magic happens. I make a post back on the OTHER RadComboBox in the top panel outside the grid in javascript. The top out of grid RadComboBox has its autopostback set to true, don't know if that is necessary if you try this example.
It worked. All of a sudden both RadComboBoxes, both the one in the grid and the one above it started working again. But I noticed the value would be lost in the grid's RadComboBox sometimes, so for giggles I added the slight pause before doing the post back of 500 ms. That did the trick. It actually would work with a very small pause, but I increased it to 500 ms for a saftey margin incase an end user was on a slow connection and that might matter.
Cluggy, cluggy, cluggy. I wish I could have just used jQuery, and used an alternative to these freaking telerik radcomboboxes, but such is life (I hear a limited version of jQuery is burried in Telerik, will experiment with that on later releases). What sucks is I bet the latest release of Telerik fixes this problem (it better), so all this poking around will end up being unnecessary when we upgrade (can't yet, some conflict with some of the customized controls that we build inheriting off of Telerik. Jan Q1 2009+ break those controls :( )
Hope this might help someone.
Another option. I ran into a scenario where I had to use lots of RadComboboxes so rather then worry about validating their contents, I just added text fields with a button next to each one that would open a radwindow with a RadComboBox so values could be chosen dynamically. On select javascript passed the selectedvalue back to the target element on the window opener page. I ran into a few headaches that I had to work though with having a bunch of context parameters set in javascript before calling the webservice on each key up (hint: with IE set the height of Radcombobox at least for 2008 Telerik versions...if you don't you will start having freezes).
Again, hope this idea is useful.

Resources