Dataform and toolkit NumericUpDown in Silverlight 5 not working as expected - silverlight-toolkit

We have just migrated an old Silverlight 4 app to Silverlight 5 and have noticed a problem with one of our Dataforms. The Dataform in question contains a NumericUpDown control from the SL5 toolkit. We have noticed that the CommitEdit doesn't appear to fire (i.e it returns false) in the following scenario:
1) Open the popup window containing the DataForm
2) Change the value in the NumericUpDown control by either clicking on the up or down arrows.
3) Click on the Save button connected to the Dataform.
The Click event code connected to the Save button is as follows:
private void OKButton_Click(object sender, RoutedEventArgs e)
{
if (updateUserDataForm.ValidateItem())
updateUserDataForm.CommitEdit(true);
else
updateUserDataForm.CancelEdit();
}
The XAML is:
<toolkit:DataField Label="Display Order" LabelStyle="{StaticResource LabelStyles}" HorizontalAlignment="Left">
<toolkit:NumericUpDown Minimum="1" Maximum="200" Value="{Binding DisplayOrder, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ValueChanged="NumericUpDown_ValueChanged"/>
</toolkit:DataField>
The CommitEdit works fine when you first give another control on the form focus before clicking on the Save button. We never had this behaviour when we were using the DatForm and NumericUpDown controls from the SL 4 toolkit. Is this an issue that has been introduced with the SL5 toolkit?

OK it appears that this is actually a bug:
http://forums.silverlight.net/t/182569.aspx/1
I have fixed it by extending the NumericUpDown control as described here:
http://silverlight.codeplex.com/workitem/4633
I'm sure this must be a bug specific to the SL5 toolkit.

Related

Child controls in asp.net Blazor not refreshing. StateHasChanged() not working

Please refer to the following https://github.com/CD1010/BlazorWizard.git for this question. The sample is in StepActivations Branch
I have a page called DemoWizard, which incorporates a 3 step wizard. When i click the "Toggle Enabled" button, the second and third steps links should go to enabled or disabled state. It seems however, that the first time takes 2 clicks to turn off the headers, and the state is always behind.
So it appears that StateHasChanged() is not refreshing child states properly.
Note that the refresh() method was an attempt to get at least step2 to refresh properly, but to no avail.
Any idea why?
the click handler that does toggle is below.
void OnClick()
{
step2Enabled = !step2Enabled;
step3Enabled = !step3Enabled;
StateHasChanged();
Step2.Refresh();
}
Your code isn't showing up exactly as advertised, but i think what you need to do is add an event callback to the Blazorize CheckEdit component:
<Blazorize.CheckEdit #bind-Checked="#Parent.IsValid" CheckedChanged="#VerifyEnabledTabs">Check Me</Blazorise.CheckEdit>
where VerifyEnabledTabs is a method on the top level Wizard that can assess where you are and what is complete / filled / checked / whatever, to allow certain links to be active.

Numeric UpDown Control for Xamarin Forms

Can any one Please provide Numeric UpDown Control demo with Xamarin Forms
Does this control Available in Xamarin Forms?
thanks
Prashanth
See edit #2.
No there is not a spinner control out-of-the-box. If you do not want to get creative, you could use the Picker control and insert predefined values into it. Picker info here.
Otherwise it would be pretty trivial to create an up and down Button and an Entry or Label. Clicking the up Button increments a number in the Entry or Label. Clicking the down Button decrements a number in the Entry or Label.
*Edit: Just happened to land on Syncfusion's NumericUpDown control which does want you want. You can also get a free community license for the control if you are a lone developer or a group of 5 or fewer people. Community License info here
*Edit #2: Was looking through the Xamarin Views list page here and saw that actually do have a Stepper control now!
You can use Stepper for this:
XAML
<Stepper Value="5"
Minimum="0"
Maximum="10"
Increment="0.1"
HorizontalOptions="LayoutOptions.Center"
VerticalOptions="LayoutOptions.CenterAndExpand"
ValueChanged="OnValueChanged" />
C#
void OnValueChanged(object sender, ValueChangedEventArgs e) {
lbldisp.Text = String.Format("Stepper value is {0:F1}", e.NewValue);
}
https://learn.microsoft.com/en-us/dotnet/api/xamarin.forms.stepper?view=xamarin-forms
maybe this could help. you might want to write a custom render for putting that textBox in between the -/+ buttons but sure if you can use as it is, it works fine.

How to disable hyperlink button in devexpress gridview

I am using devexpress for windows application. I am having a devxgrid which populates the data and at the last column, I have a hyperlink button named cancel. When I click the cancel button it will do some functionalities that is working great. After that the corresponding cancel button should be disabled. How to make it disabled? Any help is greatly appreciated.
There are two ways to implement this task:
Create two ButtonEdit repository items. One with the enabled button and another with the disabled button. Then handle the GridView.CustomRowCellEdit event and pass the necessary repository item to the e.RepositoryItem parameter according to a specific condition. Please see the Assigning Editors to Individual Cells help topic for additional information.
If the button editor has several buttons and their Enabled state must be changed dynamically, you can implement this functionality by handling the GridView.CustomDrawCell event as shown in the following DevExpress Forum thread:
How to display disabled buttons for particular cells within a ButtonEdit column
.
But you should follow the first approach, In case of hyperlinkEdit., for your implementation logic add a custom column with bool values, that will give you condition that whether you will show enabled or disabled hyperlinkEdit repository edit.
If you just want to set this readonly then you do in following way:
you can make the editor read only by handling CustomRowCellEdit:
private void gridView1_CustomRowCellEdit(object sender, CustomRowCellEditEventArgs e)
{
if(code goes here)
e.RepositoryItem.ReadOnly = true;
}
you can also prevent the editor from being show by handling ShowingEditor:
private void gridView1_ShowingEditor(object sender, CancelEventArgs e)
{
if (code goes here)
e.Cancel = true;
}
Hope this help you to solve your task..

Get access to ASP.Net CreateUserWizard buttons

I'm using a CreateUserWizard on my register page. The Sign Up button is part of a CustomNavigationTemplate.
I need to set the Sign Up button as the default button of a ASP:Panel, but can't do so since it's inside the template. I tried to do so, but I can't locate the Sign Up button using CreateUserWizard.FindControl, CreateUserWizard.WizardSteps(0).Controls(0).FindControl or other similar steps (this is a known issue with this control).
Any ideas on how I can expose this button, or set it as the panel's default button in some other way?
Here's how I finally did it:
Referencing the CreateWizard Button and assigning to Panel's Default Button:
Dim RegisterButton as Button = Ctype(CreateUserWizardStep1.CustomNavigationTemplateContainer.FindControl("RegisterButton"), Button)
RegisterPanel.DefaultButton = RegisterButton.ID 'Or RegisterButton.UniqueID
I wasn't able to use the above, because it was giving me the error "The DefaultButton of 'RegisterPanel' must be the ID of a control of type IButtonControl"
I finally created a dummy button called "RegisterButton" (same name as the register button inside the template) and hid it using CSS, and gave it's OnClick the 'real' register button's function call.
For the login section, I used this:
Page.Form.DefaultButton = LoginButton.UniqueID

Setting Focus with ASP.NET AJAX Control Toolkit

I'm using the AutoComplete control from the ASP.NET AJAX Control Toolkit and I'm experiencing an issue where the AutoComplete does not populate when I set the focus to the assigned textbox.
I've tried setting the focus in the Page_Load, Page_PreRender, and Page_Init events and the focus is set properly but the AutoComplete does not work. If I don't set the focus, everything works fine but I'd like to set it so the users don't have that extra click.
Is there a special place I need to set the focus or something else I need to do to make this work? Thanks.
We had exactly the same problem. What we had to do is write a script at the bottom of the page that quickly blurs then refocuses to the textbox. You can have a look at the (terribly hacky) solution here: http://www.drive.com.au
The textbox id is MainSearchBox_SearchTextBox. Have a look at about line 586 & you can see where I'm wiring up all the events (I'm actually using prototype for this bit.
Basically on the focus event of the textbox I set a global var called textBoxHasFocus to true and on the blur event I set it to false. The on the load event of the page I call this script:
if (textBoxHasFocus) {
$get("MainSearchBox_SearchTextBox").blur();
$get("MainSearchBox_SearchTextBox").focus();
}
This resets the textbox. It's really dodgy, but it's the only solution I could find
this is waste , its simple
this is what you need to do
controlId.focus(); in C#
controlID.focus() in VB
place this in page load or button_click section
eg. panel1.focus(); if panel1 has model popup extender attached to it, then we put this code in page load section
How are you setting focus? I haven't tried the specific scenario you've suggested, but here's how I set focus to my controls:
Public Sub SetFocus(ByVal ctrl As Control)
Dim sb As New System.Text.StringBuilder
Dim p As Control
p = ctrl.Parent
While (Not (p.GetType() Is GetType(System.Web.UI.HtmlControls.HtmlForm)))
p = p.Parent
End While
With sb
.Append("<script language='JavaScript'>")
.Append("function SetFocus()")
.Append("{")
.Append("document.")
.Append(p.ClientID)
.Append("['")
.Append(ctrl.UniqueID)
.Append("'].focus();")
.Append("}")
.Append("window.onload = SetFocus;")
.Append("")
.Append("</script")
.Append(">")
End With
ctrl.Page.RegisterClientScriptBlock("SetFocus", sb.ToString())
End Sub
So, I'm not sure what method you're using, but if it's different than mine, give that a shot and see if you still have a problem or not.
What I normally do is register a clientside script to run the below setFocusTimeout method from my codebehind method. When this runs, it waits some small amount of time and then calls the method that actually sets focus (setFocus). It's terribly hackish, but it seems you have to go a route like this to stop AJAX from stealing your focus.
function setFocusTimeout(controlID) {
focusControlID = controlID;
setTimeout("setFocus(focusControlID)", 100);
}
function setFocus() {
document.getElementById(focusControlID).focus();
}
I found the answers from Glenn Slaven and from Kris/Alex to get me closer to a solution to my particular problem with setting focus on an ASP.NET TextBox control that had an AutoCompleteExtender attached. The document.getElementById(focusControlID).focus() kept throwing a javascript error that implied document.getElementById was returning a null object. The focusControlID variable was returning the correct runtime ClientID value for the TextBox control. But for whatever reason, the document.getElementById function didn't like it.
My solution was to throw jQuery into the mix, as I was already using it to paint the background of any control that had focus, plus forcing the Enter key to tab through the form instead of firing a postback.
My setFocus function ended up looking like this:
function setFocus(focusControlID) {
$('#' + focusControlID).blur();
$('#' + focusControlID).focus();
}
This got rid of the javascript runtime error, put focus on the desired TextBox control, and placed the cursor within the control as well. Without first blurring then focusing, the control would be highlighted as if it had focus, but the cursor would not be sitting in the control yet. The user would still have to click inside the control to begin editing, which would be an UX annoyance.
I also had to increase the timeout from 100 to 300. Your mileage my vary...
I agree with everyone that this is a hack. But from the end-user's perspective, they don't see this code. The hack for them is if they have to manually click inside the control instead of just being automatically placed inside the control already and typing the first few letters to trigger the auto lookup functionality. So, hats off to all who provided their hacks.
I hope this is helpful to someone else.

Resources