The RangeExpression takes two parameters – one for min and one for max. This wasn’t clear to me at first. Consider:
<asp:RangeExpression DataField="ListPrice"
MinType="Inclusive" MaxType="Exclusive">
<asp:ControlParameter ControlID="FromTextBox" />
<asp:ControlParameter ControlID="ToTextBox" />
</asp:RangeExpression>
FromTextBox is the minimum value.
ToTextBox is the maximum value.
Found this info here. Great post!
In essence…
public class ValidationError : IValidator
{
private ValidationError(string message)
{
ErrorMessage = message;
IsValid = false;
}
public string ErrorMessage { get; set; }
public bool IsValid { get; set; }
public void Validate()
{
// no action required
}
public static void Display(string message)
{
Page currentPage = HttpContext.Current.Handler as Page;
currentPage.Validators.Add(new ValidationError(message));
}
}
ValidationError.Display("Oops, some error occurred.");
And then when you add the UIHint=”ForeignKey” you get this exception:
'XXX' is not a foreign key column and cannot be used here.
The trick is to not use the name of the foreign key column but rather the name of the auto generated navigation mechanism as mentioned here. I had trouble finding this at mechanism at first, but then realized it defaults to the name of the foreign key from the database.
Hope this saves someone the heartache!
if the user doesn’t already exist. I incorrectly assumed that it would return an error indicating the user didn’t exist.
I’m working with a client who has very detailed information buried within an XSD xs:description elements.
After much digging, I found this XSLT stylesheet which will pull out the descriptions into a nice web page.
I just whipped up a quick web page to display the results:
void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("my.xsd"));
XslTransform xslt = new XslTransform();
xslt.Load(Server.MapPath("xs3p.xsl"));
MemoryStream ms = new MemoryStream();
xslt.Transform(doc, null, ms);
ms.Seek(0, SeekOrigin.Begin);
StreamReader sr = new StreamReader(ms);
//Print out the result
Response.Write(sr.ReadToEnd());
}
}
I’ve been struggling with the built in JSON serializers in .NET. I’m using .NET on the backend to generate a JSON file to be consumed on an iOS device. The deserialization on the device will be done via SBJson (which is included with iOS Facebook connect).
JavascriptSerializer is quick and dirty as I didnt have to decorate my objects with DataContract and DataMember. However, it includes the string null for objects which are null. SBJson reads those as the string “null” which isn’t what I wanted.
I then turned to DataContractJsonSerializer. This didn’t produce the ‘null’ strings but it would require me to decorate all my classes and members which I didn’t want to take the time nor create the maintenance task of remembering to do this.
So I found JSON.NET. In about 20 minutes I had it installed, running and not spitting out the null values. A great find!
Thanks!!
I’m going to have check out this new report designer which uses a code behind file. Monoreports
I was filling in some test case data and wasn’t sure how to fill in System.Data.Linq.Binary.
Thanks to this post for helping!
I tried to created a Data Access Layer but subclassing the autogenerated classes from LINQ to SQL in .net 4.0. All was going fine until I tried to InsertOnSubmit () with the derived class. NULL Exception. After spending some time trying to overcome the problem, i decided that this is a deficiency in with LINQ to SQL and cannot be accomplished. I wonder if Entity Framework 4 has this problem. I wish I had time to investigate but, for now, I’m just including the generated class as a property in the DAL class and have moved on.
Sigh.