Telerik RadComboBox in a RadGrid Client Side Validation - asp.net

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.

Related

On Updatepanel update, everything outside the updatepanel disappears

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.

RadComboBoxItem hide() on client-side not persisting

What are you doing?
Using a RadComboBox, I'm hiding items from the user view under certain conditions.
What's the problem?
The combo items hide perfectly, however, when I click the combo box and then click anywhere else on the page (in other words, loose focus after focusing on the combobox) all the items I have hidden become visible again.
What else have you tried?
Thinking maybe I am not using the Telerik RadCombo Client Side API correctly, I decided to check whether deleted or disabled items would also magically re-appear when focusing and unfocusing from the RadComboBox.
The result; this issue only happens when hiding items, not when deleting or disabling RadComboBox items.
Demo of problem
For clarity and convenience, I've setup a page which very simply demonstrates the problem.
Download TestRadComboItemHide.zip and extract TestRadComboItemHide.aspx.
Place this ASPX into a website/webapp project and run ensuring you have telerik dll in the bin or Telerik installed on your dev computer.
Additional info
I've requsted assistance on Telerik support forums. (24 hours ago,
nothing helpful response as yet)
Using RadControls for ASP.NET AJAX Q1 2010: 2010.1.415.40
The work around to the problem is posted on the telerik forums. The solution was provided by another forum member, not Telerik.

Problem with asp.net C# focus, page_load

I'm really new to asp.net and have a couple of issues I'm trying to get fixed. I have some programming experience, but it is not asp.net. However, I've been able to follow the code enough to make other changes in the code to fix other issues.
The first is this:
I'm working with a form that has a calculate amount method that gets called when the user inputs a value in an amount text box. The same method gets called when the next control, number of payments, has a value.
So in the two controls:
onTextChanged="ctrlName_textChanged"
Then in the code behind, the textchanged method does:
calculateAmount();
The problem is after the amount is calculated and returns, the focus seems to get reset and the user has to tab all the way back through the form to the place they were.
The textboxes in question are in a panel that starts out hidden and is made visible conditionally.
My apologies if I have not used the proper .net terminology.
It looks like the same issue may be causing my second problem. When the user types in an amount and then tabs and quickly adds the number of payments, you can see the amount get calculated correctly and very shortly displays the proper total in the total amount text box. However, even though it shows for that short time, the tab order again gets reset as well as the total amount value.
I've looked at different methods to try and fix the focus issue.
In the textchanged method, I tried using something like:
Session["myval"] = "someval";
Then tried to check against that in Page_Load with something like:
if(Session["myval"] != null) {
this.NextControl_Name.Focus();
}
but it didn't ever work correctly.
I also tried to set a cookie in that same textchanged method using something like this:
Response.Cookies["myval"].Value = "somevalue";
Then tried to check that in Page_Load using something like the previous if block above but using Request.Cookies["myval"] as the source.
Is there a good reference with some really clear code samples I can look at for this type of implementation?
Thank you in advance,
C.
Sounds like you have a postback problem...
Remember that the web is stateless. This means that when you have a web page rendered out in .NET and you attach an event that executes serverside code... it does an HTTP POST back to the server which is effectively a new page request. The Page_Load method will fire again as well as your bound event. So your onTextChanged event is firing a new request back to the server. This is why you see the focus reset and why when you tab quickly, the value seems to disappear magically.
You can do one of several things, you can implement the UpdatePanel in the AjaxControlToolkit
http://www.asp.net/ajax/ajaxcontroltoolkit/samples/
you can use PageMethods and do your validation with javascript and jQuery (or other js library)
see page method info http://www.geekzilla.co.uk/View30F417D1-8E5B-4C03-99EB-379F167F26B6.htm
Hope this helps

ASP.NET : What exactly is affected when Javascript is off?

I've heard different stories about ASP.NET and JavaScript: that it works fine with Javascript turned off, that only some parts don't work, and that nothing works at all.
How exactly are ASP.NET applications affected if JavaScript is turned off in a client's browser? What parts don't work (if any)?
For example, will RequiredFieldValidators still work? What about UploadControls? AJAX UpdatePanels and AsyncPostBack's? FileUploads? Do page codebehinds still run?
Forgive my ignorance, I can't seem to find much about the issue that is in-depth.
Client-side validation and Ajax won't work, including async postbacks and any control that requires Javascript in order to work.
Server-side validation (which should always happen anyway) and full postbacks and such should always work, and i think a FileUpload control will as well. The biggest difference would be that someone wouldn't see that the data they entered happened to be invalid til the form was submitted.
LinkButtons don't work because they render out a javascript: target.
If you use GridView controls with ButtonColumns then these won't work as the buttons are javascript too. One way around this is to use a TemplateColumn and add <asp:Button> objects inside it.
Also GridView paging and sorting is JavaScript out-the-box so you'd have to write custom paging and sorting.
Also any control with AutoPostback set to true (e.g. a DropdownList) will not auto-postback. You will be able to catch the SelectedIndexChanged but ONLY when the next postback happens.
Any control that "does something" on the client side without a full page request going back to the server(ie. the whole page reloading) is done via JavaScript , and will not work with JavaScript turned off.
Remember HTML is static, so anything that "changes" in the browser window other than CSS hover effects or anything that calls back to the server without a full page reload, is done via JavaScript, and you cannot expect that to work with JavaScript disabled on the client.

Updatepanels: Prevent multiple concurrent requests by same user?

On a rather complicated screen with a big updatepanel, I'm running into the following problem:
If a user clicks on a certain button 6 or 7 times really fast, it seems to eventually process the last request out of turn and problems occur. Specifically, there's an xml document in session state, and it gets out of sync.
What I really want to do is block clicks to this button until the postback completes. I know I could probably find an easy way to do this with Javascript, but it seems like it might be built-in.
Any thoughts?
Note: The answers below are helpful, but they haven't solved the problem. After disabling the linkbutton with onClientClick and then allowing it to come back after the postback enabled again, the problem persists. It's almost as if the updatepanel isn't quite done with everything even though it has drawn the fresh, enabled linkbutton on the screen.
More notes (solved!): I solved this one by using BlockUI (jQuery plugin). See my answer below.
ASP.NET UpdatePanel always honors the last request. If you make a request while one is processing, the first requests gets terminated and the current one is processed. It was designed and built to work this way.
I would disable the button with JavaScript once it has been clicked.
UpdatePanel? I will assume you are using MS AJAX, if so I will recommend you download the AJAX toolkit if you have not done so. This toolkit comes with many ready to use controls, and extensions to help you in your AJAX enabled app. For example, there is one extension called "ConfirmButton" that will help you prevent the user from clicking in a button more than once, and it also does it in a very cool and elegant manner.
Another option will be to use JavaScript or better yet, create a custom button control that has a property to be disabled after it is clicked, if you do that, it will be really easy to reuse it in your other applications.
Hope this helps.
In a home-rolled AJAX framework I worked on awhile back, we simply logged the last call in javascript (javascript function call with many parameters) and prevented subsequent calls with identical parameters. It wasn't ideal, but it did the trick in a pinch.
I was having some "Asyc" problems with infragistics control, but after adding ScriptMode="Release" in Scripmanager the problem was resolve.
The link below solved my problem in about half an hour. Just going with a javascript disable (and I tried several different ways...) did not do the trick due to the timing of the updatepanel.
Disabling UpdatePanels While an Asynchronous Postback is in Progress

Resources