SouthSpawn:If I am using the CSLA:InvokeMethod to save my data using the dataprovide inside my XAML. What if I want a popup message box to display "After" the save has been completed.
I am not sure how do I go about doing this using the data provider.
The data provider is designed to support a simple CRUD screen and is modeled closely after the WPF data provider model. If you want more control over the process, you'll need to use code-behind or the MVVM pattern.
SouthSpawn:I have tried doing the ManualControl for the button inside my XAML, and it still disables the control. Any thoughts????
That sounds like a bug. If you tell InvokeMethod to allow manual control over the UI visual state it shouldn't alter that control's state.
Can you (or anyone else) confirm that this bug exists?
I don’t know – that code looks right to me. Does ManualEnableControl
appear in intellisense?
I just tried setting ManualEnableControl in xaml and got the same error. It shows up in intellisense, just doesn't compile. It looks like a bug, though I can't find the source of the bug in the CSLA code.
As a work around, you can set this flag programmatically in the meantime (which does compile):
Csla.Silverlight.InvokeMethod.SetManualEnableControl(buttonControl, true);
What version of CSLA .NET are you using?
Try replacing the ManualEnableControl property declaration code (static field and two methods) with the following code (from version 3.8):
/// <summary>
/// Value indicating whether the UI control should be
/// manually enabled/disabled.
/// </summary>
public static readonly DependencyProperty ManualEnableControlProperty =
DependencyProperty.RegisterAttached("ManualEnableControl",
typeof(bool),
typeof(InvokeMethod),
new PropertyMetadata((o, e) =>
{
var ctrl = o as UIElement;
if (ctrl != null)
new InvokeMethod(ctrl);
}));
/// <summary>
/// Sets the value indicating whether the UI control should be
/// manually enabled/disabled.
/// </summary>
/// <param name="ctrl">Attached control</param>
/// <param name="value">New value</param>
public static void SetManualEnableControl(UIElement ctrl, bool value)
{
ctrl.SetValue(ManualEnableControlProperty, value);
}
/// <summary>
/// Gets the value indicating whether the UI control should be
/// manually enabled/disabled.
/// </summary>
/// <param name="ctrl">Attached control</param>
public static bool GetManualEnableControl(UIElement ctrl)
{
return (bool)ctrl.GetValue(ManualEnableControlProperty);
}
I don't remember exactly why, but when I was rebuilding this control for 3.8 I know I reworked the way the attached properties are declared, and this one did give me some trouble. It works in 3.8 though, so I suspect swapping out this code may solve the issue.
Provider
in SL has Saved event you can use.
Sergey Barskiy
Principal Consultant
office: 678.405.0687 |
mobile: 404.388.1899
Microsoft Worldwide Partner of the Year | Custom
Development Solutions, Technical Innovation
From: SouthSpawn
[mailto:cslanet@lhotka.net]
Sent: Wednesday, September 30, 2009 11:10 AM
To: Sergey Barskiy
Subject: Re: [CSLA .NET] CSLA SilverLight
Rocky,
Any suggestions on how I can do a "MessageBox.Show("Company has been
updated successfully!!!")
After the DataProvider is finished with the update?
I don't see an event anywhere.
What am I overlooking?
Also What is the best way to save data on my SilverLight
Application "if" I have a "hybrid" data form with
SilverLight textbox fields as will as standard asp.net textbox fields?
Should I just get the DataProvider object from the resources collection and
manually call the save there?
This
should work
private void UpdateCompany_Button_Click(object sender,
RoutedEventArgs e)
{
p =
(Csla.Silverlight.CslaDataProvider)this.Resources["CompanyDataProvider"];
SetSummaryFromDOM();
Company c = (Company)p.Data;
c.Description = _s;
Additional
code: -
p.Saved+=(o,
e)=>
{
If
(e.Error == Null)
MessageBox.Show(“Success”);
Else
{
Messagebo.show
(“Error: “ + e.Error.Message);
}
// hide busy animation unless bound to provider
};
//
Show some busy animation unless bound to provider
p.Save();
You
would need to plug in your own error handler, messageboxes are there as an
example what to listen to.
Sergey Barskiy
Principal Consultant
office: 678.405.0687 |
mobile: 404.388.1899
Microsoft Worldwide Partner of the Year | Custom
Development Solutions, Technical Innovation
From: SouthSpawn [mailto:cslanet@lhotka.net]
Sent: Wednesday, September 30, 2009 11:53 AM
To: Sergey Barskiy
Subject: Re: [CSLA .NET] RE: CSLA SilverLight
Sergeyb,
Thanks for the response.
My last question is, how to I manually save data to the dataprovider?
In my situation, I need to use a "ScriptableMember" method to
grab some data from one of the "Html" controls on the page.
I am trying to do something alone the lines of. (This is
just an example)
private string _s;
private void UpdateCompany_Button_Click(object sender,
RoutedEventArgs e)
{
p =
(Csla.Silverlight.CslaDataProvider)this.Resources["CompanyDataProvider"];
SetSummaryFromDOM();
Company c = (Company)p.Data;
c.Description = _s;
//I am lost on what to do next.
//Since p.Data is readonly, I cannot update the object
manually by just doing a
//p.Data = c;
//p.Save();
}
private void SetSummaryFromDOM()
{
ScriptObject so =
(ScriptObject)HtmlPage.Window.GetProperty("GetDescriptionContent")
//This will call a javascript
function, that will grab the content out of an html control.
//Then it will call the
SilverLight's "Summary" method to pass that data back to the SL App.
so.InvokeSelf();
}
[ScriptableMember]
public void Summary(string s)
{
_s = s
}
Copyright (c) Marimer LLC