Monday, December 18, 2006

saving an html file from a code behind - ASP.NET

However if you really need to generate HTML output from an ASPX page it canbe easily done by overriding the Render method and capturing the output from


Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)

' *** Write the HTML into this string builder

Dim sb As StringBuilder = New StringBuilder()

Dim hWriter As HtmlTextWriter = New HtmlTextWriter(New StringWriter(sb)) MyBase.Render(hWriter)

' *** store to a string Dim PageResult As String = sb.ToString()

' *** Write it back to the server's HTTP Stream -

' *** skip this if you don't want to display the rendered content writer.Write(PageResult)

.... PageResult now hold the HTML content you can write to diskdo whatever you want to with.

End Sub

This example goes to string but you can use a StreamWriter instead of stringbuilder to dump the output directly to file if you wish.


Same in C#:


protected override void Render(HtmlTextWriter writer)
{
// *** Write the HTML into this string builder
StringBuilder sb = new StringBuilder();
HtmlTextWriter hWriter = new HtmlTextWriter(new StringWriter(sb));
base.Render(hWriter);
// *** store to a string
string PageResult = sb.ToString();
// *** Write it back to the server's HTTP Stream -// *** skip this if you don't want to display the rendered content
writer.Write(PageResult);
.... PageResult now hold the HTML content you can write out to diskdo whatever you want to with.
}

Looking for commercial use RSS weather feed by zipcode or alternative

Looking for commercial use RSS weather feed by zipcode or alternative

You can get the commercial use RSS from this website

http://www.hamweather.com/rss/

Using NotesSQL ODBC Driver and C# extract the .nsf file data

Using NotesSQL ODBC Driver and C# extract the .nsf file data to XML file format or any other format.

NoteSQL ODBC Driver Download Click Here

Sample Code:

public XmlDocument GetFromNSFdb(string strNSFdbName)

{

Domino.ISession session = new NotesSessionClass();

session.Initialize("");

Domino.NotesDatabase database = session.GetDatabase("", strNSFdbName, false); Domino.NotesNoteCollection noteCollecton = database.CreateNoteCollection(true); noteCollecton.SelectAllAdminNotes(true);

noteCollecton.SelectAllCodeElements(true);

noteCollecton.SelectAllDataNotes(true);

noteCollecton.SelectAllDesignElements(true);

noteCollecton.SelectAllFormatElements(true);

noteCollecton.SelectAllIndexElements(true);

noteCollecton.SelectForms = true;

noteCollecton.BuildCollection();

Domino.NotesDXLExporter exporter = (Domino.NotesDXLExporter session.CreateDXLExporter();

string strNsfXML = exporter.Export(noteCollecton);

// removes the string strDocrmv = strNsfXML.Replace("", "");

// removes the xmlns='http://www.lotus.com/dxl'

strDocrmv = strDocrmv.Replace("xmlns='http://www.lotus.com/dxl'", ""); XmlDocument xDocLoad = new XmlDocument();

xDocLoad.LoadXml(strDocrmv);

return xDocLoad;

}

Microsoft SecureWar Security Competition for India

Microsoft SecureWar Security Competition

Click Here to participate in this microsoft competition.

Monday, December 11, 2006

get the dimension of my document using JavaScript

to get the dimension of my document.

// javascript
var screen_width = null;
var screen_width = null;
screen_width = document.body.offsetWidth;
alert('Get IT');
screen_height = document.body.offsetHeight;
document.forms[0].txt_width.value = screen_width;
document.forms[0].txt_height.value = screen_height;

But the above script will fire only once the first time when the page is loaded.

do to execute this script every time the user resize window of the browser, use the following code part

if (self.innerWidth)
{
frameWidth = self.innerWidth;
frameHeight = self.innerHeight;
}
else if (document.documentElement && document.documentElement.clientWidth)
{
frameWidth = document.documentElement.clientWidth;
frameHeight = document.documentElement.clientHeight;
}
else if (document.body)
{
frameWidth = document.body.clientWidth;
frameHeight = document.body.clientHeight;
}
else return;
if (self.screen.width < frameWidth *2 self.screen.height < frameHeight *2)
{
newWidth = self.screen.width/2;
newHeight = self.screen.height/2;
if (document.layers)
{
tmp1 = parent.outerWidth - parent.innerWidth;
tmp2 = parent.outerHeight - parent.innerHeight;
newWidth -= tmp1;
newHeight -= tmp2;
}
parent.window.resizeTo(newWidth,newHeight);
parent.window.moveTo(self.screen.width/4,self.screen.height/4);
}
else
{
alert('No resize necessary');
}

using ArrayList for Simple Scenario (Using C#)

Scenario:

I have 2 tables one has 6 textboxes, the other has 8 rows with one textbox per row.I need to insert into a table the values in the first 6 textboxesfrom table 1 plus value from textbox 1 row 1 to textbox 8 row 8 in table 2. altogether 8 insert queries, so I will need a for loopthat will attach the values form table 1 to each value in table 2 unless the value is null.can I create an array of texboxes in table 2 so then I could loop through the array?

Solution (Using C#):

//This code to implement
ArrayList list = new ArrayList();
list.Add(new Category("textbox1"),1);
list.Add(new Category("textbox2"),2);
list.Add(new Category("textbox3"),3);
list.Add(new Category("textbox4"),4);
list.Add(new Category("textbox5"),5);
list.Add(new Category("textbox6"),6);
list.Add(new Category("textbox7"),7);
list.Add(new Category("textbox8"),8);

foreach (Category cate in list)
{
try
{
sql = "INSERT INTO DB..tAble (col1, col2) VALUES ( ";
sql += "'" + cate.Type + "', " + "'" + cate.TypeCode + "');" ;
Insertdata(sql);
}
catch(Exception ex)
{
//msg
}
}

// add this class under same namespace
public class Category
{
public string Type;
public int TypeCode;

public Category()
{
}
public Category(string type, int tcode)
{
this.Type = type;
this.TypeCode = tcode;
}
}

protected void Insertdata(string sql)
{
// Your connection and query processing for database
}

Saturday, December 09, 2006

MOSS 2007 Site templates

MOSS 2007 Site templates:

MOSS 2007 Site templates we have four category of templates

1) Collaboration

2) Meetings

3) Enterprise

4) Publishing

Collaboration:

Team Site: A site for teams to quickly organize, author, and share information. It provides a document library, and lists for managing announcements, calendar items, tasks, and discussions.

Blank Site: A blank site for you to customize based on your requirements.

Document Workspace: A site for colleagues to work together on a document. It provides a document library for storing the primary document and supporting files, a tasks list for assigning to-do items, and a links list for resources related to the document.

Wiki Site: A site for a community to brainstorm and share ideas. It provides Web pages that can be quickly edited to record information and then linked together through keywords

Blog: A site for a person or team to post ideas, observations, and expertise that site visitors can comment on.

Meetings

Basic Meeting Workspace: A site to plan, organize, and capture the results of a meeting. It provides lists for managing the agenda, meeting attendees, and documents.

Blank Meeting Workspace: A blank meeting site for you to customize based on your requirements.

Decision Meeting Workspace: A site for meetings that track status or make decisions. It provides lists for creating tasks, storing documents, and recording decisions.

Social Meeting Workspace: A site to plan social occasions. It provides lists for tracking attendees, providing directions, and storing pictures of the event.

MultiPage Meeting Workspace: A site to plan, organize, and capture the results of a meeting. It provides lists for managing the agenda and meeting attendees in addition to two blank pages for you to customize based on your requirements.

Enterprise

Document Center: A site to centrally manage documents in your enterprise.

Records Center: This template creates a site designed for records management. Records managers can configure the routing table to direct incoming files to specific locations. The site prevents records from being modified after they are added to the repository.

Site Directory: A site for listing and categorizing important sites in your organization. It includes different views for categorized sites, top sites, and a site map.

Report Center: A site for creating, managing, and delivering Web pages, dashboards, and key performance indicators that communicate metrics, goals, and business intelligence information.

Search Center With Tabs: A site for delivering the search experience. The welcome page includes a search box with two tabs: one for general searches, and another for searches for information about people. You can add and customize tabs to focus on other search scopes or result types.

My Site Host: A site used for hosting personal sites (My Sites) and the public People Profile page. This template needs to be provisioned only once per Shared Service Provider, please consult the documentation for details.

Search Center: A site for delivering the search experience. The site includes pages for search results and advanced searches.

Publishing

Collaboration Portal: A starter site hierarchy for an intranet divisional portal. It includes a home page, a News site, a Site Directory, a Document Center, and a Search Center with Tabs. Typically, this site has nearly as many contributors as readers and is used to host team sites.

Publishing Portal: A starter site hierarchy for an Internet-facing site or a large intranet portal. This site can be customized easily with distinctive branding. It includes a home page, a sample press releases subsite, a Search Center, and a login page. Typically, this site has many more readers than contributors, and it is used to publish Web pages with approval workflows.

Reference from msdn

What is the Ribbon in Office 2007

The Ribbon replaces the current system of layered menus, toolbars, and task panes with a simpler system of interfaces optimized for efficiency and discoverability.

The 2007 release of Office provides two ways to customize the RibbonX UI using XML markup:
Using valid Open XML Formats files that contain XML markup. Using COM add-ins that contain XML markup.

One of the nice article i gone through in the MSDN is ...

Code:
public void OnActionCallback(Office.IRibbonControl control, bool isPressed)
{
if (control.Id == "checkBox1")
{
MessageBox.Show("You clicked " + control.Id);
}
else
{
MessageBox.Show("You clicked a different control.");
}
}

using VSTO for visual studio 2005 we do these kind of C# coding in ribbon or add-on development for office 2007.

Demo Video for VSTO 2005 -- Visual Studio 2005 Tools for the 2007 Microsoft Office System

Demo of Visual Studio 2005 Tools for the 2007 Microsoft Office System, Second Edition

Andrew Whitechapel gives a brief demo of the new VSTO 2005 Second Edition in this video, reviewing key developer features such as new default templates, Ribbon customization, creating custom task panes, and more.

Microsoft Visual Studio 2005 Tools for Office Second Edition Runtime (VSTO 2005 SE) (x86)

The Microsoft Visual Studio 2005 Tools for Office Second Edition (VSTO 2005 SE) redistributable package installs the Visual Studio Tools for Office runtime, which is required to run solutions built using VSTO 2005 or VSTO 2005 SE.

http://www.microsoft.com/downloads/details.aspx?familyid=f5539a90-dc41-4792-8ef8-f4de62ff1e81&displaylang=en

The Microsoft Visual Studio 2005 Tools for Office Second Edition (VSTO 2005 SE) redistributable package installs the Visual Studio Tools for Office runtime, which is required to run solutions built using VSTO 2005 or VSTO 2005 SE. This runtime supports solutions built for Microsoft Office 2003 or the 2007 Microsoft Office system.For information about Visual Studio 2005 Tools for Office Second Edition, see the Microsoft Office Developer Center.

Microsoft Visual Studio 2005 Tools for the 2007 Microsoft Office System

Install VSTO 2005 SE to create new application-level add-ins for six applications in the 2007 Microsoft Office system and five in Microsoft Office 2003. Use managed code to customize task panes and the Ribbon in the 2007 Microsoft Office system applications.

http://www.microsoft.com/downloads/details.aspx?FamilyId=5E86CAB3-6FD6-4955-B979-E1676DB6B3CB&displaylang=en

VSTO 2005 SE includes support for Microsoft Office InfoPath 2007 form template projects, previously available as a separate product known as the Microsoft Office InfoPath 2003 Toolkit for Visual Studio 2005. You can now design InfoPath 2007 form solutions right in the Visual Studio 2005 environment if you have InfoPath 2007 installed on your computer.

For more click here

Thursday, December 07, 2006

Tuesday, December 05, 2006

Microsoft presents the “Microsoft BlogStars” contest


Microsoft presents the “Microsoft BlogStars” contest – hunt for the best developer bloggers in India.Create greater impact in the vibrant developer blogger community, showcase your thoughts and experiences around Microsoft technologies and technology in general.Register for the contest, start BLOGGING! and be the first ever Microsoft Blogstars!

http://www.microsoft.com/india/blogstars/

Note: Currently registration is closed

ASP.NET MVC - Sport Facility Booking system

  The project relies on some external service providers. Thus accessing them via their API requires authentication. An API Key need to be su...