Showing posts with label table. Show all posts
Showing posts with label table. Show all posts

Wednesday, March 28, 2012

Multiple ValidatorCalloutExtender controls

I have a table with multiple fields and validation controls. When I put 2 validatorcalloutextenders on the page only 1 will work on postback. For example, I have a validatorcalloutextender for to requiredfieldvalidators on my page:
1) txtWeight
2) txtProduct

Validation is set to True for my button control on the page. When clicked, only the validatorcalloutextender for txtWeight is displayed. I enter in a weight and tab out of the field and resubmit the page. The 2nd validatorcalloutextender doesn't fire.

I'm guessing that the this has something to do with the updatepanel...

Can you post your code for us?


Hi,

This is very likely be caused by that Validator isn't compatible with UpdatePanel. Please refer to this:

http://ajax.asp.net/docs/overview/UpdatePanelOverview.aspx

The following ASP.NET controls are not compatible with partial-page updates, and are therefore not supported inside an UpdatePanel control:

TreeView and Menu controls.

Web Parts controls. For more information, see ASP.NET Web Parts Controls.

FileUpload controls when they are used to upload files as part of an asynchronous postback.

GridView and DetailsView controls when their EnableSortingAndPagingCallbacks property is set to true. The default is false.

Login, PasswordRecovery, ChangePassword, and CreateUserWizard controls whose contents have not been converted to editable templates.

The Substitution control.

Validation controls, which includes the BaseCompareValidator, BaseValidator, CompareValidator, CustomValidator, RangeValidator, RegularExpressionValidator, RequiredFieldValidator, and ValidationSummary control.

And here is a workaround may help: http://blogs.msdn.com/mattgi/archive/2007/01/23/asp-net-ajax-validators.aspx

Hope this helps.


Hello,

I had already implemented the workaround (noted above in Matt's blog) before posting. I don't think the issue is with the original validation controls but rather with the callout extender. The issue is that you have to tab into the 2nd control that is being validated. If you have several controls on your form and the first control and the last control are the controls that need to be validated the last control on your page will not kick off the extender. I've attached a simple example. With this example, when you click the button the 1st extender will kick off. Enter in some text for the first textbox but DO NOT tab to the next textbox. Instead, click on the button. You will see that the extender doesn't execute for he 2nd textbox.

<%@. Page Language="VB" AutoEventWireup="false" CodeFile="testAJAX.aspx.vb"Inherits="testAJAX" %><%@. RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %><!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>Untitled Page</title></head><body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager>  </div> <asp:Button ID="Button1" runat="server" Text="Button" />        <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="t1"></asp:RequiredFieldValidator> <ajaxToolkit:ValidatorCalloutExtender ID="ValidatorCalloutExtender1" runat="server" TargetControlID="RequiredFieldValidator1"> </ajaxToolkit:ValidatorCalloutExtender> <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBox2" ErrorMessage="t2"></asp:RequiredFieldValidator> <ajaxToolkit:ValidatorCalloutExtender ID="ValidatorCalloutExtender2" runat="server" TargetControlID="RequiredFieldValidator2"> </ajaxToolkit:ValidatorCalloutExtender> </ContentTemplate> </asp:UpdatePanel> </form></body></html>

Only onbe message is shown in specific time.You should focus on other fields to see the errors.

Hmm...that kind of defeats the whole purpose of using the fancy extenders. If I have to write code to send focus to extenders based on what controls have already been validated...well, that's just down right silly!


Well, dotcarlisle's last post is marked as the Answer, but I don't see anything indicating his problem is solved! He just provided an example to reproduce the problem.

I, too am having trouble working with two calloutextenders within an updatepanel. I put dotcarlisle's sample code in a page, ran it, and followed his instructions, and the same exact thing happens in my solution. Why's that post marked as the Answer, though?

That post was done back in July, so I'm wondering if there's been a fix (yes, I have the latest AJAX relase: 10920) or a workaround provided somewhere.

Anyone have any ideas?


Hey capella07. I agree! I'm not sure why that was marked as the answer - if anything it was a mini *** session but a far cry from an answer. I also noticed that the sequence in the messages looks messed up. Why would I reply to someone's reply, or rather advertisement, for Opera?

My guess is that users get deleted and with the user goes that user's posts. In my book that seems to be a bug. THey should keep truncated user's posts around for data consistency...

Anyway, good call, Capella.


Hey, dotcarlisle. Thanks for the nod.

As a quick update, I just tried the "fix" at Matt Gibbs' blog (http://blogs.msdn.com/mattgi/archive/2007/01/23/asp-net-ajax-validators.aspx), and that didn't work.

Frankly I'm very suprised this particular issue with the Toolkit hasn't gotten more attention. Though probably not terribly frequent, seems to me it'd be somewhat common that multiple callout extenders would be needed on a page.

Monday, March 26, 2012

MutuallyExclusiveCheckBoxExtender doesnt work if elements are added dynamically

I create my table on the fly and added checkboxes as well as MECBextenders.

The client script is not working on the page. It works as expected if the MECBs are added during design time.

Here is some code to demonstrate population:

1string extenderKey ="AllTheSameKey";23foreach (MvpPoint pointin _selected.FolderPoints)4 {5678switch (point.PointType)9 {10case tPointType.DO:11case tPointType.CP:12 {13continue;14 }15default:16 {17 trow =new TableRow();1819 CheckBox chkSelected =new CheckBox();20string sPointId = point.Handle.ToString();21 chkSelected.ID ="chk" + sPointId;22 chkSelected.Visible =true;23if (point.PointType == tPointType.AI)24 chkSelected.Enabled =true;25else26 chkSelected.Enabled =true;2728 AjaxControlToolkit.MutuallyExclusiveCheckBoxExtender chkExtender =new AjaxControlToolkit.MutuallyExclusiveCheckBoxExtender();29 chkExtender.ID ="chkExt" + sPointId;30 chkExtender.TargetControlID = chkSelected.ID;31 chkExtender.Key = extenderKey;32

The problem ONLY exists if the MutuallyExclusiveCheckBoxExtender is cointeined inside a TabPanel. The IDs get changed by the cointeiner control and the jscript fails to find them.

Saturday, March 24, 2012

Need an idea for clientside-loaded control container

I am working on an Expandable Row Extender that ideally youwould apply on a gridview (or any other databound control that renders a table)to give it an expandable row functionality. However, I want to do as much aspossible in client side (I've seen the approach of adding an item in thedataset, override onitembound to draw it accordingly and then rebind the datato the control to redraw it, and place it all in an update panel but I don'tlike this approach - obvious reasons). Nor do I like the idea of having every"details" row rendered and hidden.

I kind of like how this feels:http://www.codeproject.com/aspnet/MasterDetail.asp and I very much like how asimilar implementation on www.titlez.com.

That being said, I am trying to make the control as genericas possible (and as easy to use as possible), therefore I think the easiest foranybody to use for the details row would be a usercontrol (so that you can useyour own control, which eventually you might reuse as a webpart as well).

Here is where I need the idea: how to dynamically render thecontrol triggered from the client side (to render it in the expanded row).

The trivial solution would be to use an iframe and load aweb form that would load the control, but there is something that doesn't feelright about this approach.

Any ideas?

I think you can embed user controls to a GridView and implement a inline GridView similar to the demo in www.titlez.com.Besides,maybe a third party user control can be used in a GridView,specially about Chart/Graph controls.
Try to take a look at Ajax website - http://Ajax.asp.net.There are a lot of useful Ajax controltoolkit which can help you to implement it and get a nice web page.

Hi Jasson and thank you for your reply.

I know you can embed user controls in a gridview but what I am trying toachieve is a control that does as much as possible on client side (so when youwould expand a row I wouldn't want to hit the server to add a control in thegrid and rebind the grid, even if this would be in an updatepanel especially asyou might have some time-consuming info in the details row and if you wouldhave several open at the same time this architecture would severely affectperformance. Nor do I want to pre-render everything in one go and initiallyhide the rows for the same reason). Also I am not interested at this time aboutthe graphs and other nice things in those rows, I am just down to the very ideaof the extender control. I am well aware of the ajax controls toolkit and what I am doing isan extender using the same framework, actually extending the extenderbase inthe toolkit.

What I have done so far uses IFrames to render the details row and lets youdefine a usercontrol that will be rendered in the expanded row. It goes througha complicated process of autogenerating a form to host the control at runtime.I was looking for ideas of how to do this without IFrames, using somethingsimilar to an updatepanel that would be able to add the user control atruntime.

Hope this makes sense ..


If you would like to achieve a control as much as possible on the client side,javascript is the unique selection.Ajax control toolkit gives us a good direction to this,however,it can not implement what we need now.I believe it can be done in the near future.I agree with you that if we load too many user controls at runtime in the server side and embed them in a complicated control such as Grivew,DetailsView or FormView,it will affect the server performance. Do you mind MagicAjax which also provides a Ajax framework for us to do further development?MagicAjax is open source and we can extend it to meet our requrements.I don't know if you are inerested in it.

Try to take a look at this reading about MagicAjax for your reference -http://www.c-sharpcorner.com/UploadFile/mosessaur/magicajax02112006060506AM/magicajax.aspx?ArticleID=ddd4757e-7ab7-49da-a3f2-d88b340230c3

Wish this can give you some ideas.


Thanks for sharing the idea. I am afraid I am familiar with MagicAjax as well but I don't see it solving this particular issue. MagicAjax is actiong more like the UpdatePanel control in Ms. Ajax. That wouldn't work without rebinding the grid on the server which wouldn't be any faster. Further more, MagicAjax stores everything on the session so it might bring even more concerns.

Need code for Drag and Drop Div ...

Hello All...

i have two tables where i have 3 div in 1 one table and 3 Divs in other table.

i want that i can drag any DIV of 1st tables DIV to 2nd TABLES Div and can paste on it..

i went to several solutions but they are providing solutions for HardCord Named DIVS not for Runtime Created DIVs.

pls help me...

It shouldn't work any differently. You just need to assign IDs to the divs when you create them and then assign the behaviors to those IDs. Perhaps if you post the code you are using to create the divs as well as what solution you want to use (I personally like the prototypes at http://script.aculo.us).


Yes. Check these sample for clues

http://www.codeproject.com/aspnet/DragAndDropShopping.asp

http://elouai.com/javascript-drag-and-drop.php

HTH,
Suprotim Agarwal

--
http://www.dotnetcurry.com
--


i am basically creatingDIV dynamically through CODE and i want to paste them on each other

i am not getting any help from http://script.aculo.us site and other answers of my post forums

How can i assign values & Ids of different DIV created at runtime in my JavaScript ?? can u give me a sample code ...

Thank You


var parent = document.getElementById('parentDiv');
var newdiv = document.createElement('div');
var divID = 'myNewDiv;
newdiv.setAttribute('id',divID);
newdiv.innerHTML = 'Element has been added!';
parent.appendChild(newdiv);


http://www.dhtmlgoodies.com/index.html?page=dragDrop