Showing posts with label ajaxcontroltoolkit. Show all posts
Showing posts with label ajaxcontroltoolkit. Show all posts

Wednesday, March 28, 2012

Change Textbox background with ValidatorCallout.

Hi All,

I want to replicate what is done here:

http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ValidatorCallout/ValidatorCallout.aspx

When the submit button is clicked, the 'name' and 'phone number' backgrounds change color...

Any help would be great.

Thanks

Keegan

Hi Keegan,

There is a pretty good sample contained inside the AJAX Control Toolkit's source code. You can find it under SampleWebSite\ValidatorCallout directory. Here is the sample code. Please pay attention to the "Bold" part.

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"></script><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title> <style> .validatorCalloutHighlight { background-color: lemonchiffon; } </style></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <table> <tr> <td>Name:</td> <td><asp:TextBox runat="server" ID="NameTextBox" BorderStyle="solid" BorderWidth="1px" BorderColor="#a9a9a9" /></td> </tr> <tr> <td>Phone Number:</td> <td><asp:TextBox runat="server" ID="PhoneNumberTextBox" BorderStyle="solid" BorderWidth="1px" BorderColor="#a9a9a9" /></td> </tr> </table> <br /> <asp:RequiredFieldValidator runat="server" ID="NReq" ControlToValidate="NameTextBox" Display="None" ErrorMessage="b><br />A name is required."> <ajaxToolkit:ValidatorCalloutExtender runat="Server" ID="NReqE" TargetControlID="NReq" HighlightCssClass="validatorCalloutHighlight" /> <asp:RequiredFieldValidator runat="server" ID="PNReq" ControlToValidate="PhoneNumberTextBox" Display="None" ErrorMessage="b><br />A phone number is required.<div style='margin-top:5px;padding:5px;border:1px solid #e9e9e9;background-color:white;'><b>Other Options:</b><br /><a href='javascript:alert("No phone number available in profile.");'>Extract from Profile</a></div>"> <ajaxToolkit:ValidatorCalloutExtender runat="Server" ID="PNReqE" TargetControlID="PNReq" HighlightCssClass="validatorCalloutHighlight" Width="350px" /> <asp:RegularExpressionValidator runat="server" ID="PNRegEx" ControlToValidate="PhoneNumberTextBox" Display="None" ValidationExpression="((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}" ErrorMessage="b><br />Please enter a phone number in the format:<br />(###) ###-####"> <ajaxToolkit:ValidatorCalloutExtender runat="Server" ID="PNReqEx" TargetControlID="PNRegEx" HighlightCssClass="validatorCalloutHighlight" /> <asp:Button ID="Button1" runat="server" Text="Submit"/><br /><br /> </form></body></html>

I hope this help.

Best regards,

Jonathan


Hi Jonathan,

Thank you very much for the reply. It pointed me in the right direction:

I created a class in my linked CSS file:.validatorCalloutHighlight{background-color:Red;}

and set the property of myValidatorCalloutExtender to call:HighlightCssClass="validatorCalloutHighlight".

Worked like a charm.

Thanks again.

Keegan

Saturday, March 24, 2012

CascadingDropDown: Pulling selected values from a cookie

I am using the CascadingDropDown extender from the AjaxControlToolkit and I was wondering if there was an easy way to set the selected value and to populate child drop downs when the page loads. I am storing a users previous selections in a cookie so when they start a new form these values are already selected. I did some looking at the CascadingDropDown code but I didn't see an easy way to accomplish this. Does anyone know an easy way to do it?

Or am I going to have to cobble some JS together to make it happen?

Thanks.

Derek

Couldn't you just do something like

myCascadingDropdownListExtender.SelectedValue = Request.Cookies("MyCookie")

on Page_Load ? It works for me.

CascadingDropDown, FormView, ObjectDataSource, Optimistic Concurrency and Delete

Greetings,


We have recently upgraded a web site from "atlas" July 06 to use AJAX 1.0 (1.0.61025.0) and AjaxControlToolkit March 07 (1.0.10301.0). As you can imagine, we had to "tweak" a fair amount of code but in short, all is now working minus one major point.


We have a middle-tier DataAccessLayer that simply uses Microsoft's XSD's to connect to Oracle 9i and we make use of the Optimistic Concurrency feature. The front-end web with FormViews and Cascading dropdowns consumes the ObjectDataSource and works great on Insert and Update. But Deletes fail due to optimistic concurrency. It seems that only on deletes, the "Original_fieldname" values are NULL for any dropdown wired to a cascading control. However, "Original_fieldname" values are correct when UPDATE is clicked. Only when DELETE is clicked does the FormView fail to populate to original values and thereby the ObjectDataSource has NULL values as well.


Any ideas? Thanks!

Unfortunately, use of the CascadingDropDown isn't fully compatible with standard data-bound drop downs. The CascasdingDropDown expects to pick up it's data from the async web service call.

Off the top of my head, I'm not sure how those field values get populated, but I suspect it's part of the <%# Bind() %> functionality. The CascadingDropDown might be overwriting those values. You might be able to work around this by trapping the delete and filling in the value before the command is sent to the ObjectDataSource.


Thanks for the info. We used your suggestion in the ObjectDataSource_Deleting event and supplied all of the "original_xxx" InputParameters with values from a lookup to the record in question. Kind of a hack and somewhat defeats the purpose of optimistic concurrency, but it will do for now. Aside from that, the work your team has done on the toolkit is amazing. Keep it up!

CascadingDropDown using SQL in VB example anyone?

I'm new to using the AjaxControlToolkit, and I'm finding lots of variations in the examples out there. I would like to use the CascadingDropDown control to populate a State, and Country drop down. I am using ASP 2.0, and I'm developing code using Visual Web Developer 2005 Express. The data files reside on a separate SQL 2000 server.

Does anyone have a good example out there? All of the tutorial videos either use an XML file for the data, or have tags that are no longer supported in the latest tool kit (like CascadingDropDownProperties).

I had the same problem with the Ajax Tab controls (lots of different versions), but figured that one out. Not finding much on the web.

Any help would be greatly appreciated.

Hi and welcome to the forums.

Have you checked this tutorial.http://www.asp.net/AJAX/AjaxControlToolkit/Samples/Walkthrough/CCDWithDB.aspx. Though this is in C#, it is very simple. Try to convert it yourself or else try this tool to convert from C# code to VBhttp://labs.developerfusion.co.uk/convert/csharp-to-vb.aspx. If you still have problems, then post it here and we will convert it.

All the best.


Yes, I've viewed that video. What would I have to change to make the example in this video point to SQL tables? Or, If I convert my Country table, and State table to one XML file, how would I handle countries with no states?

I would really like to find an example that uses the current Ajax Control Toolkit for ASP.Net 2.0 that uses SQL tables. In the meantime, I'll try and make the example work with my own XML Country/State data.

Thanks.