Geeks With Blogs
Łukasz Kuryło's blog August 2011 Entries
Using XSLT with ASP.NET controls
In my previous post I have shown how we can use a C# function in the XSLT. Now I want to go one step further and use in the transformation the ASP.NET controls along with their events. Let's start from the sample xml data: <files> <file Id="F58C2962-AC0D-4C55-80A8... Name="file 1" Path="D:\Temp\" Extension="iso"/> <file Id="FDC1358E-D9C8-4A70-ABE0... Name="file 2" Path="D:\Temp\" Extension="jpg"/> </files> I want to create a table from it and for each ......

Posted On Friday, August 26, 2011 12:57 PM

Using custom functions in Xsl
Using Xslt along with XPath we can transform any xml document in the way we want and use it e.g. to create the html page. At this time, we have Xslt 2.0 and XPath 2, but unfortunatelly .Net Framework doesn't support them. We can only use Xslt 1. We have two ways to work with Xslt 2. One is to use a 3rd party library, e.g. XQSharp or Saxon. The second option is to manually implement the missed in Xslt 1 functions. How to do it I want to show in this post. First is the sample code. The goal is to create ......

Posted On Wednesday, August 24, 2011 10:42 PM

Using stored procedures with NHibernate
NHibernate has many ways to create and executes queries. With one of them* - the Named Queries we can execute our manually created stored procedures. This example is dedicated to SQL Server. This is important to notice, because this code is database specified. That means, for each database the query can look diffrent. E.g. in SQL Server we call the stored procedure by using the syntax: exec <procedure>. In Oracle it is: call <procedure>, so we must remember it. Let's assume we have a ......

Posted On Wednesday, August 24, 2011 12:12 AM

Aliasing the data returned as xml
I just wanted to return from sql server data as xml. This is very easy to do, because sql server has a build-in suppot for that. select Id, Name from Extensions FOR XML RAW('Extension'), ROOT('Extensions') But using this query, the returned column has name like XML_F52E2B61-18A1-11d1-B105... It's been some time when I manually created a sql query, so I lost few minutes to think, how to alias this column using the AS keyword. Correct query looks as follows select (select Id,Name from Extensions ......

Posted On Tuesday, August 23, 2011 5:57 PM

Disabling the browser-default functonality in WinForms WebBrowser control
The WebBrowser control uses behind the scenes the IE engine to render the pages. Fortunatelly/Unfortunatelly is that, we have together with the rendered page the IE-default shortcuts, the context menu shown after pressing the right mouse button etc. To disable e.g. refreshing the page by pressing F5, we can set the WebBrowserShortcutsEnabled property to false. To disable the context menu, the WebBrowser control have either a property, called IsWebBrowserContextMenuEnab... When we set it to false, ......

Posted On Monday, August 22, 2011 3:13 PM

Updating WinForms progress bar using Tasks from Task Parallel Library
I'm not a desktop application developer. I wrote only one app using the WinForms, but I must tell, it was interesting experience. Now I'm writting second WinForms app and second time, I needed the possibility to updating the progress bar in an app. So I think this is a good opportunity to put on the blog the code snippet for that to have a place where I can have some useful code for future references. Ok, so let's go to the solution details. As every desktop application developer know (or should ......

Posted On Wednesday, August 17, 2011 5:42 PM

Converting XmlDocument to XDocument and vice versa
In my previous posts I have shown how to get xml data from database and deserialize it. But sometimes we want to work with the xml and do some operations on it. To working with xml, in the .net framework there are two tools for it. One is to use the XmlDocument class and second is the linq to xml with the XDocument class. I personally prefer to work with linq to xml, so I must convert the XmlDocument object to XDocument which I have after I took the xml from database. To convert the XmlDocument to ......

Posted On Wednesday, August 17, 2011 2:15 PM

Useful snippet for serializing/deserializing data
In one of my previous posts I have used my custom code to serialize and deserialized data to/from XmlDocument class. Examples of use: XmlDocument extensions=//some xml document taken from db List<FileExtension> result = SerializationUtils.DeSerial... List<FileExtension> extensions=//some new objects to save to database XmlDocument serializedExtensions = SerializationUtils.Serializ... ......

Posted On Wednesday, August 17, 2011 2:01 PM

Simple wrapper for ISession and ITransaction
In my previous post I have used a OperationsInTransaction.Exe... method. This is my simple wrapper for the NHibernate ISession and ITransaction method. Normally when we want to execute some query in the transaction we must write this piece of code using (ISession session = SessionFactory.OpenSession()) { using (ITransaction transaction = session.BeginTransaction()) { try { //some query transaction.Commit(); } catch (Exception) { transaction.Rollback(); } } } Unfortunatelly we must write it every ......

Posted On Wednesday, August 17, 2011 1:51 PM

Using NHibernate with xml column
I have a simple database table with only id and one xml column as shown below. In this column I have a list of available extensions saved as xml. public class FileExtensionsList { public FileExtensionsList() { Id = Guid.NewGuid(); } public virtual Guid Id { set; get; } public virtual XmlDocument Extensions { set; get; } } This xml I'm not creating manually. I have a custom entity which I serialize to xml: [XmlRoot("FileExtensionsLis... [Serializable] public class FileExtension { [XmlAttribute] public ......

Posted On Wednesday, August 17, 2011 1:35 PM

Playing with update panels
I'm an Asp.Net web developer, but the truth is, I always preferred the MVC than WebForms. Especially what I hate in WebForms is the update panel control. I have always problems with it when I want to use it in my current scenario, so easier to me is to write some jQuery code and do the controls refresh manually. I know that, there are situatios when I can't skip the update panels, so this post is a reference for my future battles. A simple example of one update panel with button and some labels. ......

Posted On Monday, August 8, 2011 11:51 AM

Copyright © Łukasz Kuryło | Powered by: GeeksWithBlogs.net