Thursday, December 11, 2014

Export Dataset To XML File asp net c#

System.Data.DataSet ds;
//Fill dataset
 
// Get a FileStream object
using (System.IO.StreamWriter xmlDoc = new System.IO.StreamWriter(Server.MapPath("~/writeabledir/xmlDoc.xml"), false))
{
 // Apply the WriteXml method to write an XML document
 ds.WriteXml(xmlDoc);
}

Saturday, December 6, 2014

jQuery ui dialog change title after load-callback

Save dialog in a variable

$dialog = $("#dialog-message").dialog({
   modal: true,
   autoOpen: false,
   buttons: {
   Ok: function () {
   $(this).dialog("close");
   }
   }
});
$('[data-action="show"]').click(function () {
   //Change title
   $dialog.dialog('option''title', $(this).data('product'));
   //Open dialog
   $dialog.dialog('open');
 
   return false;
});

Friday, December 5, 2014

How to combine date from one field with time from another field - MS SQL Server

SELECT CAST(MyDate AS DATETIME) + CAST(MyTime AS DATETIME) AS CombinedDateTime
 
--OR
--if date part is missing and you want to format time in asp net
SELECT CAST(GETDATE() AS DATE) + CAST(MyTime AS DATETIME) AS CombinedDateTime

MultiView cannot have children of type

Multiview must be followed by the following type
  1. CompleteWizardStep
  2. CreateUserWizardStep
  3. TemplatedWizardStep
  4. ViewWizardStep
And make sure runat="server" is applied on each tag

Thursday, December 4, 2014

Get class from string in asp net c# using Reflection

Assembly assembly = Assembly.Load("AssemblyName.ClassName");
Class class = (Class)assembly.CreateInstance("AssemblyName.ClassName"true);

asp net c# Get executing assembly name

// Full-name, e.g. MyApplication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
string exeAssembly = Assembly.GetEntryAssembly().FullName;
 
// or just the "assembly name" part (e.g. "MyApplication")
string exeAssemblyName = Assembly.GetEntryAssembly().GetName().Name;