Showing posts with label property. Show all posts
Showing posts with label property. Show all posts

Wednesday, March 28, 2012

Programmatically defining the FilteredTextBoxExtender FilterType Property

Hi there!

I'm toying with the FilteredTextBoxExtender for a web portal we're developping at job, and thought it would simpler to define different data-entry textboxes.

With that objective in mind, I created a web user control that include a FilteredTextBoxExtender, its TextBox, some public properties to access underlying controls properties (like TextBox.Text, FilteredTextBoxExtender.FilterMode, etc.), plus a 'BoxType' private member (Type = internal enum) that's gonna define the different TextBoxes we might need (Postal codes, zip codes, money, Person namem email, and so on...)

Intended use is to simply drag the WUC on a page, define its _boxType member value, et voilĂ !

Problem is, I make a verification in the page_Load event of the WUC regarding the _boxType, and then would set the underlying extender's FilterType and ValidChars properties. But when I try to set a value for the FilterType property, I can't use more than one! The Toolkit references page says that you can use a '[...]comma-separated combination ofNumbers,LowercaseLetters,UppercaseLetters, andCustom[...]' but it won't accept the '+' operator for different FilterTypes, won't cast from string to FilterTypes (and vice versa)..

Anyone knows if that's intended?

Hi,

It's aflag enumeration. In ASP.NET's declarative markup you can specify multiple values with commas, but in C# you use the bitwise or operator |. For example, myExtender.FilterTypes = FilterTypes.UppercaseLetters | LowercaseLetters.

Thanks,
Ted


Thank you so very much, Ted. That did the trick!

And I'll most probably face that behavior a couple of times, thanks for the insight!

Monday, March 26, 2012

Programmatically setting ConfirmText of ConfirmButtonExtender

I was wondering if it's possible to set the ConfirmText of the CBE programatically at run-time?
I can't seem to access the ConfirmText property in my VB code.

ThanksYes, it is. The code looks something like:

<%@. Page Language="VB" %><%@. Register Assembly="AtlasControlToolkit" Namespace="AtlasControlToolkit" TagPrefix="atlasToolkit" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) CBE.TargetProperties(0).ConfirmText = "Here I am" End Sub</script><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <div> <atlas:ScriptManager ID="SM" runat="server"> </atlas:ScriptManager> <asp:Button ID="Button1" runat="server" Text="Button" /> <atlasToolkit:ConfirmButtonExtender ID="CBE" runat="server"> <atlasToolkit:ConfirmButtonProperties TargetControlID="Button1" ConfirmText="You can't see me" /> </atlasToolkit:ConfirmButtonExtender> </div> </form></body></html>

Property animation in javascript.

How do i perform a property animation in javascript? the code below does not do anything... anything wrong?

offSet = 40;
controlSize = 19;
animation = new AjaxControlToolkit.Animation.PropertyAnimation(
panel,
0.25,
100,
'style',
'height');
animation.setValue(offSet + numOfControls*controlSize + "px");
animation.play();

Hi ,

Try setting the Width Property to "null" in the ReSize animation .

Ex :

//AjaxControlToolkit.Animation.ResizeAnimation.play(target, duration, fps, width, height, unit);

AjaxControlToolkit.Animation.ResizeAnimation.play( $get("ID") , 0.3 , 125 ,null , 500 ,"px" );

Hope this helps


HI,

I am assuming that resolved it .

Feel free to correct me .


Hey,

Another way to increase only the height .

AjaxControlToolkit.Animation.LengthAnimation.play(panel, 0.25, 50 ,

'style' ,'height', 100 , 400 ,'px');

This is better than the Resize animation with the width set to null.

Property Page for Controls?

Ok, I may just be a complete idiot, but are there extended property pages available for the controls in the toolkit at design time?

For instance, the PasswordStrength extender has a property calledTextStrengthDescriptions but as far as I can see, it is not on the properties page.

The documentation states it is initialized with this code:

<ajaxToolkit:PasswordStrength ID="PS" runat="server" TargetControlID="TextBox1"DisplayPosition="RightSide"StrengthIndicatorType="Text"PreferredPasswordLength="10"PrefixText="Strength:"TextCssClass="TextIndicator_TextBox1"MinimumNumericCharacters="0"MinimumSymbolCharacters="0"RequiresUpperAndLowerCaseCharacters="false"TextStrengthDescriptions="Very Poor;Weak;Average;Strong;Excellent"TextStrengthDescriptionStyles="cssClass1;cssClass2;cssClass3;cssClass4;cssClass5CalculationWeightings="50;15;15;20" />

But for the life of me, I cannot find this block of code anywhere - so I end up having to set the values in code. Can anyone tell me where the above init code is located or how to access the other non-displayed properties of a control in the designer?

Thanks!

Hi,

Please download the sample applicationhere, then open the PasswordStrength.aspx page, you will find it in the html source.

Property value disappear on click with user control

Hi,

I have a user control which require input text boxes and a caclulate button. When I hit the recalculate button, lblMonth becomes blanks. Please see the code below and guide how to keep the lblMonth the value of lblMonth

============
<asp:UpdatePanel ID="upPanelSales" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="lblMonth" runat="server" Font-Bold="true" ForeColor="white" CssClass="heading" />
-- some text box controls
<asp:Button ID="btnReCalc" runat="server" Text="Recalc." CommandName="Calculate" CommandArgument="ReCalc" OnCommand="Calculate" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnReCalc" EventName="Command" />
</Triggers>
</asp:UpdatePanel
Code Behind
Private _MonthNameAs String

Public Property MonthName()As String
Get
Return _MonthName
End Get
Set(ByVal valueAs String)
_MonthName = value
End Set
End Property

Protected Sub Page_PreRender(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Me.PreRender
Me.lblMonth.Text = _MonthName
End Sub

Protected Sub Calculate(ByVal senderAs Object,ByVal eAs CommandEventArgs)
If e.CommandName ="Calculate"Then
Select Case e.CommandArgument
Case"ReCalc"
ReCalculate()
End Select
End If
End Sub

Main Page
=========

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" />
<Sales:Input ID="uc" runat="server" />
Code Behind

Sub Page_Load
uc.MonthName = Month1
End Sub

you probably want to do this in your main page code behind so it only gets set when the page loads the first time

Sub Page_Load

if not Page.IsPostBack Then
uc.MonthName = Month1
end if
End Sub


My main page contains 4 link button controls called Qtr1, Qtr2, Qtr3, Qtr4 and I want to change the month value based on user clicking on quarter links? The real problem is due to submit button inside the user control and partial page refresh has applied on this user control.


so you solved it? or you're still asking?

if those 4 links are outside of the updatepanel they will trigger a full post back and the data inside the update panel contents will be treated no differently than if they weren't inside an updatepanel.

if you click the the linkbutton inside the updatepanel the only thing that will happen is the data within the updatepanel will postback and the associated button event will fire. Only data within the updatepanel will post back to the server though. Data outside of the updatepanel will still appear to the server as the same data regardless of change on the client side...

Property value undefined after succesfull web service call

Hello,

hopefully I can explain my problem.

I started to create extended control with ajax control toolkit. Idea is, that I have textfield which works so

that it suggest values every time when user hits key. Like that --> http://www.google.com/webhp?complete=1&hl=en

Now in SearchTextBoxBehavior.js file I have two propertys, which one hold id for listbox which shows suggestions.
(I think in that google example, the control is span or div element.)


Ok, I have succesfully created event, which is occurred when user hits key in textfield. Webservice call is made in bold code line-->

1_onkeyup : function() {
23 var targetButton = $get(this._TargetButtonID);
4 var targetListBox = $get(this._TargetListBoxID);
5
6if(targetButton && targetListBox) {
7 targetButton.disabled =true;
8
9// unescape() convert′s a string to URL-encoded form10 var searchValue = unescape(this.get_element().value);
11
12if(searchValue !="") {
13// Set suggestion visible14 targetListBox.style.visibility ="visible";
15
16MyCompany.WebServices.MySearch.GetDataTableFromWebservice(searchValue,this._onSucceeded);
17 }
18else {
19// Set suggestion hidden when there is no search value inserted20 targetListBox.style.visibility ="hidden";
21 }
22 }
23
24 },
 
Web service call is succesfull, and returns into function:
 
1_onSucceeded : function(Result) {23var targetListBox = $get(this._TargetListBoxID);45var table = Sys.Preview.Data.DataTable.parseFromJson(Result);67...89}
 
Problem is, that in that _onSucceeded function, propertythis._TargetListBoxID is
undefined. In function, where I made web service call, the property was ok, and I could
make instance about control.
 

Hi,

you need to modify the context under which the callback is executed. This can be done with a delegate and the Function.createDelegate method:

MyCompany.WebServices.MySearch.GetDataTableFromWebservice(searchValue,Function.createDelegate(this, this._onSucceeded));



Hi,

it worked, thanks. :)


Yesterday evening I managed to circulate problem, with solution below.

1var inputParams =new Array();2inputParams[0] =this._TargetListBoxID;3inputParams[1] =this._TargetButtonID;4inputParams[2] =this._ListControlTextField;5inputParams[3] =this._ListControlValueField;67MyCompany.WebServices.MySearch.GetDataTableFromWebservice(searchValue,this._onSucceeded,this._onFailed, inputParams);

Hi,

yes, as your code shows, you're passing a context object as the last parameter to the proxy method. This is useful especially if you want to access only certain references in the callback and not the whole instance.


Hi All,

huygens...is there any way you can post your full code? I'm looking to do something similar with the toolkit. Would be greatly appreciated.

Saturday, March 24, 2012

Q: problem with setTimeout function

Hello everybody!

What I am trying to achieve is the following thing. I have a textbox and a control extender to the textbox. I have a property called - FadeAnimation which can be true or false. If it is true, the following thing should happen. When the user focuses the textbox, it should change the opacity of the textbox.

It always keeps giving me that the method is not supported at the setTimeout line. Any suggestions?

//run the onfocus function var focus =this.get_element(); var focusDelegate = Function.createDelegate(this,this._onfocus); $addHandler(focus,"onfocus", focusDelegate);this._onfocus(); }, _onfocus : function() {this._opacity(); },//Function to change the opacity _opacity : function() { var id =this.get_element(); var opacStart = 0; var opacEnd = 100; var millisec = 250; var speed = Math.round(millisec / 100);var timer = 0;if(opacStart > opacEnd){for( i = opacStart ; i >= opacEnd ; i--){setTimeout("this._changeOpac(" + i +")", (timer * speed));timer++;}}else if(opacStart < opacEnd){for(i = opacStart; i <= opacEnd; i++){setTimeout("this._changeOpac(" + i +")", (timer * speed));timer++;}} }, _changeOpac : function(opacity) { varobject =this.get_element().style;object.background ='#FFFF99';object.opacity = (opacity / 100);object.MozOpacity = (opacity / 100);object.KhtmlOpacity = (opacity / 100);object.filter ="alpha(opacity=" + opacity +")"; },// TODO: (Step 2) Add your property accessors here get_FadeAnimationProperty : function() {return this._FadeAnimationPropertyValue; }, set_FadeAnimationProperty : function(value) {this._FadeAnimationPropertyValue =value; }
try window.setTimeout()

I'm not a Javascript guru by any means, but i think that your problem is that with this line

setTimeout("this._changeOpac(" + i +")", (timer * speed));

you lose, hmmm not sure if this is the right term to use, "context" of the object "this" as the event isn't raisedwithin