Wednesday, 8 December 2010
how to configure DHCP in windows server 2003?
Here is some links for configuring DHCP in the local network:
1. http://www.windowsreference.com/windows-server-2003/install-and-configure-dhcp-server-in-win-server-2003-step-by-step-guide/
2. http://www.windowsnetworking.com/articles_tutorials/DHCP_Server_Windows_2003.html
Tuesday, 23 November 2010
How to get the path of AppData for an application?
Here is the link
http://stackoverflow.com/questions/946420/allow-access-permission-to-write-in-program-files-of-windows-7
And here is my code for getting the AppData folder
XmlDocument xmldoc = new XmlDocument();
string xmlfilepath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
//loading the file
xmldoc.Load(xmlfilepath + "/" + "enstatics.xml");
//returning the xmldoc
return xmldoc;
DNS setup in Ubuntu Linux
Here is a post I created for DNS setup in Ubuntu Linux with BIND software.
DNS setup in ubuntu
Here is the link http://cseku.technopeople.net/setting-up-dns-linux.aspx
Working with xml file in C#
1. Creating xml file dynamically
2. Modifying the xml file
3. Reading from the xml file.
Creating XML file dynamically
//code for creating and saving default config public void create_config_xml_file() { try { //xml doc XmlDocument xmldoc = new XmlDocument(); //xml declaration XmlDeclaration xmldeclaration = xmldoc.CreateXmlDeclaration("1.0", "utf-8", null); //create root element XmlElement rootNode = xmldoc.CreateElement("myconfigdata"); xmldoc.InsertBefore(xmldeclaration, xmldoc.DocumentElement); xmldoc.AppendChild(rootNode); //adding more children to the root node //imageformatindex XmlElement ifiElement = xmldoc.CreateElement("imageformatindex"); ifiElement.InnerText = "1"; rootNode.AppendChild(ifiElement); //currentdirectory XmlElement currDirElement = xmldoc.CreateElement("currentdirectory"); currDirElement.InnerText = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); rootNode.AppendChild(currDirElement); //fileprefix XmlElement fpElement = xmldoc.CreateElement("fileprefix"); fpElement.InnerText = "ISeeStand"; rootNode.AppendChild(fpElement); //filesuffixid XmlElement fsElement = xmldoc.CreateElement("filesuffixid"); fsElement.InnerText = "2"; rootNode.AppendChild(fsElement); //sequential XmlElement seqElement = xmldoc.CreateElement("sequential"); seqElement.InnerText = "0"; rootNode.AppendChild(seqElement); //sequentialvid XmlElement seqVidElement = xmldoc.CreateElement("sequentialvid"); seqVidElement.InnerText = "0"; rootNode.AppendChild(seqVidElement); //videncoder XmlElement videncElement = xmldoc.CreateElement("videncoder"); videncElement.InnerText = "WMVideo9 Encoder DMO"; rootNode.AppendChild(videncElement); //framesize XmlElement fsizeElement = xmldoc.CreateElement("framesize"); fsizeElement.InnerText = "800 x 600 @5.00 fps"; rootNode.AppendChild(fsizeElement); //framerate XmlElement frateElement = xmldoc.CreateElement("framerate"); frateElement.InnerText = "5.00 fps"; rootNode.AppendChild(frateElement); //getting appdata folder string app_path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); //saving that document xmldoc.Save(app_path+"/"+"enstatics.xml"); } catch (Exception exc) { MessageBox.Show("Failed to create the xml configuration file."+exc.Message); } }From the above code, we can see how to use XMLDocument object and XmlNode for creating a XML file.
Modifying the XML file
The following code saves some info into the xml file accessing a particular XmlNode
//saving the image format index to the xml file try { XmlDocument xmldoc = MyStaticMgr.loadMyXMLDoc(); XmlNode formatIndexNode = xmldoc.GetElementsByTagName("imageformatindex")[0]; //setting the preferences to the xml node formatIndexNode.InnerText = (ImageformatComboBox.SelectedIndex + 1).ToString(); //now saving the xml file int result=MyStaticMgr.saveMyXMLDoc(xmldoc); } catch (Exception exc) { MessageBox.Show("Failed to save the preferences"+exc.Message); }Reading from XML file
The following code will demonstrate how to access a particular node of the xml file for a particular information//making a default choice try { XmlDocument xmldoc = MyStaticMgr.loadMyXMLDoc(); XmlNode formatIndexNode = xmldoc.GetElementsByTagName("imageformatindex")[0]; int format_index = int.Parse(formatIndexNode.InnerText); //now setting that index to the combobox ImageformatComboBox.SelectedIndex = format_index - 1; } catch (Exception exc) { string messageBoxText = exc.Message; string caption = "Exception Occurred"; MessageBox.Show(messageBoxText, caption); }From the above codes we found a particular section like this
XmlDocument xmldoc = MyStaticMgr.loadMyXMLDoc();and
//now saving the xml file int result=MyStaticMgr.saveMyXMLDoc(xmldoc);Actually, MyStaticMgr is a static class which handles the basic operation like opening an xml document and returning the document object or saving the xmldocument object. Here is the code
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Xml;using System.Windows.Forms;namespace ISeeStand{ public static class MyStaticMgr { //code for loading the xml document public static XmlDocument loadMyXMLDoc() { XmlDocument xmldoc = new XmlDocument(); string xmlfilepath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); //loading the file xmldoc.Load(xmlfilepath + "/" + "enstatics.xml"); //returning the xmldoc return xmldoc; } //code for saving to the xml file public static int saveMyXMLDoc(XmlDocument xmldoc) { int saved = 0; try { string xmlfilepath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); //loading the file xmldoc.Save(xmlfilepath + "/" + "enstatics.xml"); //yes the file is saved saved = 1; } catch (Exception exc) { string messageBoxText = exc.Message; string caption = "Exception Occurred"; MessageBox.Show(messageBoxText, caption); } //returning the result return saved; } }}
Sunday, 29 August 2010
Handling event from Context Menu strip after a Right Click
- Windows form
- ListView Control
- ContextMenu Strip
Step-1:Loading listview items::
The following code loads the items to listview control.
protected void load_courses()
{
//code for loading the courses
try {
OleDbConnection conn = new OleDbConnection(StaticData.connection_string);
conn.Open();
string select_courses = "select * from Course";
OleDbDataAdapter oda = new OleDbDataAdapter(select_courses, conn);
DataTable dt = new DataTable();
oda.Fill(dt);
//databinding to the listview
TestlistView.Items.Clear();
for(int i=0;i < dt.Rows.Count;i++)
{
DataRow row = dt.Rows[i];
ListViewItem lvi = new ListViewItem(row["CourseNo"].ToString());
lvi.SubItems.Add(row["CourseID"].ToString());
lvi.SubItems.Add(row["Credit"].ToString());
TestlistView.Items.Add(lvi);
}
}
catch (Exception exc) { }
}
private void Form1_Load(object sender, EventArgs e)
{
//code for loading the courses
load_courses();
}
Step-2:Handling the right click event on listview items:
private void TestlistView_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
Point pt = TestlistView.PointToScreen(e.Location);
contextMenuStrip1.Show(pt);
}
}
Step-3:Handling context menu strip event
private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
if (e.ClickedItem.Text == "Upload")
{
MessageBox.Show("Upload started for:" + TestlistView.SelectedItems[0].Text);
}
}
Thats how we can use right click event to show a context menu strip and handle menu strip click events.
thanks. Masud(29-08-2010)
Thursday, 6 May 2010
Full functional LAN set up
A Web server
Here is the necessary help for that1. http://blog.ifitcangowrong.com/windows/install-iis-60-on-windows-server-2003
2. http://technet.microsoft.com/en-us/library/aa998483%28EXCHG.65%29.aspx
3. http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/750d3137-462c-491d-b6c7-5f370d7f26cd.mspx?mfr=true
A DNS Server
Here is necessary help for that I think:1.http://www.petri.co.il/install_and_configure_windows_2003_dns_server.htm
2.http://helpdeskgeek.com/networking/install-and-configure-dns-on-windows-server-2003/
3. http://support.microsoft.com/kb/814591
An Email sever (POP and SMTP)
1. http://www.ilopia.com/Articles/WindowsServer2003/EmailServer.aspx2. http://www.windowsreference.com/windows-server-2003/step-by-step-email-server-setup-in-windows-server-2003/
3. http://articles.techrepublic.com.com/5100-10878_11-5035180.html
4. http://www.windowsnetworking.com/articles_tutorials/Windows_POP3_Service.html
Tuesday, 20 April 2010
Using image map and popupcontrol extender
Step-1: We have to register the AjaxControlToolkit for using its control which we are calling here PopupControlExtender.
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
Step-2:
Consider an image containing lots of hot spot and when there is a click on that hot spot certain popup-winow will show up. So, here is the code for image and map.
< img id="homeimg" src="maps/map-bg-w-dots.jpg" style="border-width:0px" runat="server" alt="" usemap="#homemap" / >
< map name="homemap" id="homemap">
< area id="hole1area" runat="server" target="_self" onclick="showdetails(1)" shape="circle" style="cursnor:pointer" alt="" coords="314,178,7"/>
< area id="hole2area" runat="server" target="_self" onclick="showdetails(2)" shape="circle" style="cursor:pointer" alt="" coords="285,56,7"/>
< /map>
Here, onclick="showdetails(1)" can be used to populate data from some xml file relevant to hole1area if needed. As for example I have done in
my map project
Step-3:
Now we need the popup control extender that will generate a popup. So, here is the code below:
< asp:ScriptManager runat="server">< /asp:ScriptManager>
< cc1:PopupControlExtender runat="server" ID="MyPopupExtender1" OffsetX="550" OffsetY="300" PopupControlID="popupwindow1" TargetControlID="hole1area">
< /cc1:PopupControlExtender>
< cc1:PopupControlExtender runat="server" ID="MyPopupExtender2" OffsetX="550" OffsetY="300" PopupControlID="popupwindow2" TargetControlID="hole2area">
< /cc1:PopupControlExtender>
< div id='popupwindow1'>
Description for hole1...............
< /div>
< div id='popupwindow2'>
Description for hole2................
< /div>
Here, several thing to notice:
TargetControlID= the control which will be clicked on.
PopupControlID= the control which will be shown as popup.
OffsetX= the X position where popup will be shown
OffsetY= the Y position where popup will be shown.
So, this is the simplest way to use image map and popupcontrolextender. And whenever I started working client become excited as I was not using his solution but finally I ended up with good solution and he was quite satisfied. So, this project was one of the challenging task to me.
thanks. Masud.
