Search This Blog

2009-07-20

How to place both VB and CS File in App_Code directory

The single App_Code directory can only contain files of the same language.

However, you can add subdirectories to the App_Code directory
in order to process multiple languages under the App_Code directory.

In order to do this, you need to register each subdirectory in the application's Web.config.

<configuration>
<system.web>
<compilation debug="false">
<codeSubDirectories>
<add directoryName="VBFiles"/>
<add directoryName="CSFiles"/>
</codeSubDirectories>
</compilation>
</system.web>
</configuration>

Then, simply creating the App_Code\VBFiles and App_Code\CSFiles directories,
and placing your VB and CS files in each, will allow you to use both languages in your app.

2009-07-09

F# As a Language and F# for Developers

F# As a Language:

F# includes support for the foundational features of functional programming including tuples, lists, options, function values, local function definitions, pattern matching and sequence expressions.

The powerful type inference mechanisms of F# allow code to be both succinct and yet fully type-checked.

F# also includes support for advanced functional programming constructs such as active patterns and computation expressions. Computation expressions can be used to express data queries and client/server modalities in AJAX-style web programming. They enable programmers to write succinct and robust reactive agents through the use of asynchronous workflows. Computation expressions are related to ``monads'' in Haskell.

F# embraces object-oriented programming and includes support for type-inferred, succinct descriptions of object types.

F# allows types and values in an F# program to be accessed from other .NET languages in a predictable and friendly way.

F# includes support for a form of meta-programming, inspired by LINQ. This allows data queries to be expressed and type-checked in F# code and then dynamically compiled and translated to target languages such as SQL using the LinqToSql framework.

F# fully supports .NET generics and the language was designed partly with this in mind.

Through .NET, F# supports advanced language and runtime features such as Unicode strings, dynamic linking, preemptive multithreading, and SMP support.

F# for Developers:

The F# Interactive environment fsi.exe supports top-level development and exploration of the dynamics of your code and environment.

The command line compiler fsc.exe supports separate compilation, debug information and optimization.

F# comes with Visual Studio integration that supports features such as an integrated build/debug environment, graphical debugging, interactive syntax highlighting, parsing and typechecking, IntelliSense, CodeSense, MethodTips and a project system.

F# can be used with tools from the .NET Framework, Microsoft's Visual Studio and many other .NET development tools.

F# comes with an ML compatibility library that approximates the OCaml 3.06 libraries. This means you don't have to use .NET libraries if it is not appropriate. It is possible to write large and sophisticated applications that can be cross-compiled as OCaml code or F# code, and we take this mode of use seriously.

Resource obtain from http://research.microsoft.com/en-us/um/cambridge/projects/fsharp/about.aspx

What is F#

F# is a functional programming language for the .NET Framework. It combines the succinct, expressive, and compositional style of functional programming with the runtime, libraries, interoperability, and object model of .NET.

F# stems from the ML family of languages and has a core language compatible with that of OCaml, though also draws from C# and Haskell. F# was designed from the ground up to be a first-class citizen on .NET, giving smooth interoperability with other .NET languages. For example, C# and F# can call each other directly. This means that F# has immediate access to all the .NET Framework APIs, including, for example, Windows Presentation Foundation and DirectX. Similarly, libraries developed in F# may be used from other .NET languages.

Caml is a general-purpose programming language, designed with program safety and reliability in mind. It is very expressive, yet easy to learn and use. Caml supports functional, imperative, and object-oriented programming styles.

The oCaml or Objective Caml system is the main implementation of the Caml language. It features a powerful module system and a full-fledged object-oriented layer. It comes with a native-code compiler that supports numerous architectures, for high performance; a bytecode compiler, for increased portability; and an interactive loop, for experimentation and rapid development.

2009-07-02

Check file type of FileUpload control for asp.net

This can be achived by
-input type="file" instead of asp:FileUpload
-A server side Textbox Control

Following is a Code snippet of file upload control where I am only accepting the files which has an extension "sas7bdat".If the file extension is not sas7bdat ,I am showing a messge and clear the textbox if the textbox has some value otherwise the selected file name along with the path will come to the textbox.

Code Snippet:


<table>
<tr>
<td class="input-label-left">
Select Data File :
</td>
<td class="input-label-left">
<asp:TextBox ID="txtDataFile" runat="server" ToolTip="Select a .sas7bdat file to attach"></asp:TextBox>
</td>
<td class="input-label-left">
<input id="fupldDataFile" title="Select a .sas7bdat file to attach" type="file" runat="server" onchange="return load_DataFile();" style="width: 10px; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid;" />
</td>
</tr>
</table>


<script language="javascript" type="text/javascript">
function load_DataFile()
{

var Filepath = document.getElementById('<%= fupldDataFile.ClientID %>').value;
if(Filepath != "")
{
var arr1 = new Array;
arr1 = Filepath.split("\\");
var len = arr1.length;
var File1 = arr1[len-1];
var filext = File1.substring(File1.lastIndexOf(".")+1);

if (filext != "sas7bdat")
{
alert("Invalid File Format..Selected");
h = '<input title="Select a .sas7bdat file to attach" enableviewstate="true" onChange="return load_DataFile();" type="file" style="BORDER-RIGHT: white 1px solid; BORDER-TOP: white 1px solid; BORDER-LEFT: white 1px solid; WIDTH: 10px; BORDER-BOTTOM: white 1px solid" id="ctl00_RMHolder1_TabContainer1_pnlInput_fupldDataFile" name="ctl00$RMHolder1$TabContainer1$pnlInput$fupldDataFile"></td><td width="192" valign="middle">'
document.getElementById('<%= fupldDataFile.ClientID %>').outerHTML =h;
document.getElementById('<%= txtDataFile.ClientID %>').value="";
return false;
}
else
{
document.getElementById('<%= txtDataFile.ClientID %>').value=document.getElementById("ctl00_RMHolder1_TabContainer1_pnlInput_fupldDataFile").value;

}
}
return;
}
</script>

tags:How do I Validate the File Type of a File Upload,Check file extension of FileUpload control