Friday, June 25, 2010
Embed a True Type Font on your web page.
You may have an interesting or weird font type that you want on your web page, but in order for other people to be able to see this font you will need to embed it on your web page. Why? Because when a visitor views a web site, the only fonts that will display are those installed on the visitors system!
So if you want either a weird gothic font or an old Celtic font such as in the main logo of my site (which is actually an image) you will need to either display the font in an image or embed the font in your web page.
NOTE:: Although this guide is new it is based on old information. I will try to update it as soon as I have time.
Embedding the font:
To embed a font type on a Web page first select the font you want to embed, either from your hard drive or download it from the Internet.
Then create an embedded font file. And lastly attach the font to your style sheet.
Creating the Embedded File
You need to download software to create an embedded font file which can be in two formats .pfr or .eot.
Portable Font Resources (.pfr):
TrueDoc for Nav 4.0+ and IE 4.0+ on Windows, Mac, and Unix platforms.
Download from http://Bitstream.com
Embeddable Open Type[/b] (.eot):
Compatible only with Explorer 4.0+ on the Windows platform.
Download from http://www.microsoft.com/typography/web/embedding/weft3/default.htm
Next we need to embed the file using CSS.
Into the HEAD section of your document insert:
Example with True Type
To work in IE4 and above, you need to add a pointer to an ActiveX control immediately after the LINK tag OR ELSE create an OpenType file for Explorer and refer to both on your page.
TrueDoc fonts stay within the browser: you can't download them to your system
Example with Open Type
This method works in IE5 & IE6 but is not supported by Firefox/Opera.
Wednesday, March 3, 2010
Windows Workflow Foundation
Workflow is one of the new core capabilities (along with WPF aka Avalon and WCF aka Indigo) being added in the .NET Framework 3.0 release later this year. It provides an in-process workflow engine to process rules, a designer for VS 2005 to enable both developers and non-developers to define custom workflow processes graphically, and a new Workflow namespace to integrate these within code
ASP.NET and Workflows
A workflow built on Windows Workflow Foundation is a component that requires an ad hoc runtime environment to function. The workflow runtime environment is represented by the Workflow Runtime class. To host a workflow library, you create and configure an instance of the Workflow Runtime class to operate on a particular workflow type. For performance reasons, you normally create the runtime environment only once in the application lifetime and make it serves all incoming requests. In a Windows Forms application, you initialize the workflow runtime in the form's constructor and destroy it with the form when the application shuts down. So how does this work if you're using ASP.NET?
Once you have a workflow component up and running, calling it from within a Web app or Windows Forms shouldn't be an issue. As far as Windows Workflow Foundation-based workflows are concerned, ASP.NET developers have only a few small issues to face that are mostly related to the nature of Web applications.
Just like in Windows Forms, with ASP.NET you need to have just one instance of the workflow runtime created when the application starts. Unlike Windows Forms applications, though, a Web application works by accepting and processing requests. Requests are treated individually and don't know anything about each other. That leads to issues related to workflow persistence and threading.
WF (Windows Workflow Foundation) Features:-
· WF (Windows Workflow Foundation) supports sequential or state machine workflows. Sequential workflows usually co-ordinate activities that have a well-defined order and particular business rules and decision-making logic controls the flow between activities. Sequential workflows can contain purely automated processing, or can wait for external input from humans or external system events. State machine workflows allow the workflow to respond to external events that trigger further processing and transitions to other states.
· Developers / programmers use the Workflow Designer mixed with their associated Visual Studio environment to organize activities into a workflow definition that meets business requirements. Business users can review the resulting workflow design to see the implementation and verify that it meets their requirements.
· With use of workflow, complex business rules can be decoupled from application code making them easily to create, change & maintain. The WF (Windows Workflow Foundation) designer offers a way to specify business rules separate from other workflow logic.
· Workflows (WF) can encapsulate details for a complex business process including decision-making logic and business rules that can impact flow of communication, error handling, and compensating activities.
· Developers can easily encapsulate common workflow logic for the business domain into custom activities that can be reused across workflows and hide the complexity of a particular subset of logically related activities. Higher level, domain specific activities can also become building blocks for business analysts to design workflow definitions.
· The state of a long running workflow can be managed and traced with built-in services WF (Windows Workflow Foundation) offers for persistence and tracking.
· Human workflow can be integrated such that different applications and users can act with a particular workflow illustrate at different stages of execution.
Regard
Prateek Bhatnagar
Friday, February 19, 2010
Microsoft .NET Framework 4.0
Microsoft .NET Framework
The Microsoft .NET Framework is a software framework that can be installed on computers running Microsoft Windows operating systems. It includes a large library of coded solutions to common programming problems and a virtual machine that manages the execution of programs written specifically for the framework. The .NET Framework is a Microsoft offering and is intended to be used by most new applications created for the Windows platform.
In this articles we talk about Microsoft .NET Framework 4.0
What’s new in .NET Framework 4.0?
1. Next versions of Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) will provide better support for Web 2.0 technologies like REST, POX, and ATOM.
2. Performance and Scalability of WCF and WF are expected to increase by minimum 10X.
3. New workflow models.
4. Seamless integration between WCF and WF including a new Visual Designer.
5. Parallel Programming framework using PLINQ, Task Parallel Library and Coordination Data Structures to better utilize power of multi-processor and multi-core machines.
6. Build declarative applications with WF, WCF and WPF using XAML. So, XAML is no more only for WPF and WF.
7. WCF enhancements:
1. RESTful enhancements
1. Simplifying the building of REST Singleton & Collection Services, ATOM Feed and Publishing Protocol Services, and HTTP Plain XML Services using WCF
2. WCF REST Starter Kit to be released on Codeplex to get early feedback
2. Messaging enhancements
1. Transports - UDP, MQ, Local in-process
2. Protocols - SOAP over UDP, WS-Discovery, WS-Business Activity, WS-I BP 1.2
3. Duplex durable messaging
3. Correlation enhancements
1. Content and context driven, One-way support
4. Declarative Workflow Services
1. Seamless integration between WF and WCF and unified XAML model
2. Build entire application in XAML, from presentation to data to services to workflow
8. WF enhancements:
1. Significant improvements in performance and scalability
1. Ten-fold improvement in performance
2. New workflow flow-control models and pre-built activities
1. Flowcharts, rules
2. Expanded built-in activities – Power Shell, database, messaging, etc.
3. Enhancements in workflow modeling
1. Persistence control, transaction flow, compensation support, data binding and scoping
2. Rules composable and seamlessly integrated with workflow engine
4. Updated visual designer
1. Easier to use by end-users
2. Easier to rehost by ISVs
3. Ability to debug XAML
Regard
Prateek Bhatnagar
Wednesday, February 3, 2010
Upload Image in Database and Display Image
Id --> int (identity column, and primary key)
firstname -->varchar(50)
lastname -->varchar(50)
image -->varchar(50)
and under my web site root directory i have created a folder with name..(images)
here is the code.. to upload the image....
using System.IO;
using System.Data.SqlClient;
using System.Web.Configuration;
protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
string fileExt = Path.GetExtension(FileUpload1.FileName).ToLower();
string fileName = Path.GetFileName(FileUpload1.FileName);
string dbfilePath = @"~/images/" + fileName;
if (fileName != string.Empty)
{
try
{
if (fileExt == ".jpg" || fileExt == ".gif")
{
FileUpload1.SaveAs(Server.MapPath(@"~/images/") + fileName);
}
else
{
Response.Write("You can upload only JPG or GIF files...");
}
}
catch (Exception ex)
{
throw ex;
}
}
SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["myConnection"].ConnectionString);
SqlCommand cmd = new SqlCommand("insert into images values(@firstname,@lastname,@image)",con);
cmd.Parameters.AddWithValue("@firstname",TextBox1.Text);
cmd.Parameters.AddWithValue("@lastname",TextBox2.Text);
cmd.Parameters.AddWithValue("@image",dbfilePath);
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
if (i > 0)
{
Response.Write("Uploaded");
}
}
}
Display Image in Repeater
his is how you can display the images in Repeater control....
Html...
CodeBehind...
using System.Data.SqlClient;
using System.Web.Configuration;
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["myConnection"].ConnectionString);
SqlCommand cmd = new SqlCommand("select * from images",con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
Repeater1.DataSource = dt;
Repeater1.DataBind();
}
Regard
Prateek
Install Silver Light
Mostly many person not know how to install silverlight so,follow this steps:
1 Microsoft visual studio 2008 (SP1)
2 Silverlight tool.exe
3 Microsoft Expression Blend 2.0
4 Microsoft Expression Blend 2.0 (SP1)
5 Silverlight tool kit 2 March
Regard
Prateek
Wednesday, December 30, 2009
Delete Type URL from AddressBar
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Security.Permissions;
using Microsoft.Win32;
using System.Windows.Forms;
using System.IO;
[assembly: RegistryPermission(SecurityAction.RequestMinimum, ViewAndModify = "HKEY_CURRENT_USER\\SOFTWARE\\MICROSOFT\\INTERNET EXPLORER\\TYPEDURLS")]
[assembly: RegistryPermission(SecurityAction.RequestMinimum, ViewAndModify = "HKEY_CURRENT_USER\\SOFTWARE\\MICROSOFT\\INTERNET EXPLORER")]
then declare below static constant string varible:
public static SortedList
public const string REG_URL = "SOFTWARE\\MICROSOFT\\INTERNET EXPLORER\\TYPEDURLS";
public const string REG_URL_SHORT = "SOFTWARE\\MICROSOFT\\INTERNET EXPLORER";
then here is the code for:
GetHistory();
int deletedhist = 0;
using (RegistryKey tempKey = Registry.CurrentUser.OpenSubKey(REG_URL, true))
{
if (tempKey == null)
{
System.Windows.Forms.MessageBox.Show("The registry entry for " + REG_URL + " does not exist!",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
} // if
else
{
foreach (histlink hl in historylinks.Values)
{
tempKey.DeleteValue(hl.URL);
deletedhist++;
}
}
}
GetHistory();
lbl_message.Text = "Typed URL's cleared";
and here is the code for gethistory function:
public void GetHistory()
{
historylinks.Clear();
using (RegistryKey tempKey = Registry.CurrentUser.OpenSubKey(REG_URL))
{
if (tempKey == null)
{
using (RegistryKey tempKeyShort = Registry.CurrentUser.OpenSubKey(REG_URL_SHORT, true))
{
if (tempKeyShort == null)
{
MessageBox.Show("The registry entry for " + REG_URL_SHORT + " does not exist!",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
else
{
tempKeyShort.CreateSubKey("TypedURLs", RegistryKeyPermissionCheck.ReadWriteSubTree);
}
}
}
}
using (RegistryKey tempKey = Registry.CurrentUser.OpenSubKey(REG_URL))
{
if (tempKey == null)
{
System.Windows.Forms.MessageBox.Show("The registry entry for " + REG_URL + " does not exist!",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
string[] vals = tempKey.GetValueNames();
int itemcounter = 0;
foreach (string url in vals)
{
object keyValue = tempKey.GetValue(url);
if (keyValue != null)
{
histlink hl = new histlink();
string entry = keyValue.ToString();
if (entry.Length != 0)
{
itemcounter++;
hl.Entry = entry;
hl.URL = url;
historylinks.Add(itemcounter, hl);
}
}
}
}
Deleting historyfile
and the code is:
//textBox is used for deleting particular history file
string enteredtext = txt_url.Text.Trim();
string lowertext = txt_url.Text.ToLower();
string uppertext = txt_url.Text.ToUpper();
string[] historyfile = Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.History), "*", SearchOption.AllDirectories);
for (int i = 0; i < historyfile.Count(); i++)
{
try
{
File.Delete(historyfile.ElementAt(i));
lbl_message.Text = historyfile.ElementAt(i)+ " cleared";
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
//this is the function which I used :
public void GetHistory()
{
historylinks.Clear();
using (RegistryKey tempKey = Registry.CurrentUser.OpenSubKey(REG_URL))
{
if (tempKey == null)
{
using (RegistryKey tempKeyShort = Registry.CurrentUser.OpenSubKey(REG_URL_SHORT, true))
{
if (tempKeyShort == null)
{
MessageBox.Show("The registry entry for " + REG_URL_SHORT + " does not exist!",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
else
{
tempKeyShort.CreateSubKey("TypedURLs", RegistryKeyPermissionCheck.ReadWriteSubTree);
}
}
}
}
using (RegistryKey tempKey = Registry.CurrentUser.OpenSubKey(REG_URL))
{
if (tempKey == null)
{
System.Windows.Forms.MessageBox.Show("The registry entry for " + REG_URL + " does not exist!",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
string[] vals = tempKey.GetValueNames();
int itemcounter = 0;
foreach (string url in vals)
{
object keyValue = tempKey.GetValue(url);
if (keyValue != null)
{
histlink hl = new histlink();
string entry = keyValue.ToString();
if (entry.Length != 0)
{
itemcounter++;
hl.Entry = entry;
hl.URL = url;
historylinks.Add(itemcounter, hl);
}
}
}
}