Feb 4, 2011

Java script for Number Only ....

<HTML>
<HEAD>
<TITLE>Letting Only Numbers Pass to a Form Field</TITLE>
<SCRIPT LANGUAGE="JavaScript">
function checkIt(evt) {
    evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        status = "This field accepts numbers only."
        return false
    }
    status = ""
    return true
}
</SCRIPT>
</HEAD>

<BODY>
<H1>Letting Only Numbers Pass to a Form Field</H1>
<HR>
<FORM onSubmit="return false">
Enter any positive integer: <INPUT TYPE="text" NAME="numeric" 
    onKeyPress="return checkIt(event)">
</FORM>
</BODY>
</HTML>

Feb 3, 2011

Add, modify, Delete and Clear In XML File

Add four buttons to web page, Add, modify, Delete and Clear
Add 2 functions: One is loadXmlData, and the other is FindXmlData
//insert data to xml file
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim xmldoc As XmlDocument = New XmlDocument()
xmldoc.Load(Server.MapPath("App_Data\smallfools.xml"))

Dim newelement As XmlElement = xmldoc.CreateElement("poems")
Dim xmlAuthor As XmlElement = xmldoc.CreateElement("author")
Dim xmlTitle As XmlElement = xmldoc.CreateElement("title")
Dim xmlContent As XmlElement = xmldoc.CreateElement("content")

xmlAuthor.InnerText = Me.TextBox1.Text.Trim()
xmlTitle.InnerText = Me.TextBox2.Text.Trim()
xmlContent.InnerText = Me.TextBox3.Text.Trim()

newelement.AppendChild(xmlAuthor)
newelement.AppendChild(xmlTitle)
newelement.AppendChild(xmlContent)

xmldoc.DocumentElement.AppendChild(newelement)
xmldoc.Save(Server.MapPath("App_Data\smallfools.xml"))

loadXmlData()
End Sub
//modify one xml data base on selecteditem
 Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim xmldoc As XmlDocument = New XmlDocument()

xmldoc.Load(Server.MapPath("App_Data\smallfools.xml"))
If Int32.Parse(Me.lblSelectIndex.Text) = -1 Then
Me.RegisterClientScriptBlock("alertmessage", "<script>alert('please select one modify data item.')</script>")
Else
Dim xmlnode As XmlNode = xmldoc.DocumentElement.ChildNodes.Item(Int32.Parse(Me.lblSelectIndex.Text))
xmlnode("author").InnerText = Me.TextBox1.Text.Trim()
xmlnode("title").InnerText = Me.TextBox2.Text.Trim()
xmlnode("content").InnerText = Me.TextBox3.Text.Trim()
xmldoc.Save(Server.MapPath("App_Data\smallfools.xml"))
End If
loadXmlData()
End Sub
//Delete one xml data base on selecteditem
 Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim xmldoc As XmlDocument = New XmlDocument()
xmldoc.Load(Server.MapPath("App_Data\smallfools.xml"))
Dim xmlnode As XmlNode = xmldoc.DocumentElement.ChildNodes.Item(Int32.Parse(Me.lblSelectIndex.Text))
xmlnode.ParentNode.RemoveChild(xmlnode)
xmldoc.Save(Server.MapPath("App_Data\smallfools.xml"))
loadXmlData()
Me.TextBox1.Text = ""
Me.TextBox2.Text = ""
Me.TextBox3.Text = ""
End Sub
//clear textbox value
Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click
Me.TextBox1.Text = ""
Me.TextBox2.Text = ""
Me.TextBox3.Text = ""
End Sub
//load xml data from xml file
 Private Sub loadXmlData()
Dim myDs As DataSet = New DataSet()
myDs.ReadXml(Server.MapPath("App_Data\smallfools.xml"))

If myDs.Tables.Count <> 0 Then
Me.GridView1.DataSource = myDs
Me.GridView1.DataBind()
End If


End Sub
//select one data and fill data to textbox
 Private Sub FindXmlData(ByVal selectedIndex As Integer)
Dim xmldoc As XmlDocument = New XmlDocument()

xmldoc.Load(Server.MapPath("App_Data\smallfools.xml"))
Dim xmlnodelist As XmlNodeList = xmldoc.DocumentElement.ChildNodes
Dim xmlnode As XmlNode = xmlnodelist.Item(selectedIndex)
Me.textBox1.Text = xmlnode("author").InnerText
Me.textBox2.Text = xmlnode("title").InnerText
Me.textBox3.Text = xmlnode("content").InnerText
End Sub

Showing and hiding details in a datagrid row in Asp.net

Visit this linked article on codeproject.com

http://www.codeproject.com/KB/aspnet/csviewdetails.aspx

Feb 2, 2011

How to call a ServerSide Script through Javascript

How to call a ServerSide Script through Javascript

I used a query string from Javascript ,something like

Var windid = window.open("default.aspx?frameheight="+mapframeheight+"&framewidth="+mapframewidth+"");

Which sends these values to the server.

Hope it helps.

Feb 1, 2011

ZatakTextBox : ALL IN ONE TEXT BOX

This textbox contains everything for validation. You can set validation options by a click of the mouse and just a few keystrokes.

http://www.codeproject.com/KB/validation/ZatakTextBox.aspx

AxWindowsMediaPlayer.uiMode Property

Remarks

This property specifies the appearance of the embedded Windows Media Player. When uiMode is set to "none", "mini", or "full", a window is present for the display of video clips and audio visualizations. This window can be hidden in mini or full mode by setting the height attribute of the OBJECT tag to 40, which is measured from the bottom, and leaves the controls portion of the user interface visible. If no embedded interface is desired, set both the width and height attributes to zero.
If uiMode is set to "invisible", no user interface is displayed, but space is still reserved on the page as specified by width and height. This is useful for retaining page layout when uiMode can change. Additionally, the reserved space is transparent, so any elements layered behind the control will be visible.
If uiMode is set to "full" or "mini", Windows Media Player displays transport controls in full-screen mode. If uiMode is set to "none", no controls are displayed in full-screen mode.
If the window is visible and audio content is being played, the visualization displayed will be the one most recently used in Windows Media Player.
If uiMode is set to "custom" in a C++ program that implements IWMPRemoteMediaServices, the skin file indicated by IWMPRemoteMediaServices.GetCustomUIMode is displayed.
During full-screen playback, Windows Media Player hides the mouse cursor when enableContextMenu equals false and uiMode equals "none".

Examples

The following example creates a list box that allows the user to change the user interface mode for an embedded Windows Media Player object. The AxWMPLib.AxWindowsMediaPlayer object is represented by the variable named player.


// Load the list box with the four UI mode options.
uiModeOptions.Items.Add("invisible");
uiModeOptions.Items.Add("none");
uiModeOptions.Items.Add("mini");
uiModeOptions.Items.Add("full");


private void uiModeOptions_OnSelectedIndexChanged(object sender, System.EventArgs e)
{
    // Get the selected UI mode in the list box as a string.
    string newMode = (string)(((System.Windows.Forms.ListBox)sender).SelectedItem);
     
    // Set the UI mode that the user selected.
    player.uiMode = newMode; 
}

WindowsMediaPlayer.fullScreen Property

Property Value

A System.Boolean value that indicates whether content is played in full-screen mode. The default value is false.

Remarks

For full-screen mode to work properly when embedding the Windows Media Player control, the video display area must have a height and width of at least one pixel. If uiMode is set to "mini" or "full", the height of the control itself must be 65 or greater to accommodate the video display area in addition to the user interface.
If uiMode is set to "invisible", then setting this property to true raises an error and does not affect the behavior of the control.
During full-screen playback, Windows Media Player hides the mouse cursor when enableContextMenu equals false and uiMode equals "none".
If uiMode is set to "full" or "mini", Windows Media Player displays transport controls in full-screen mode when the mouse cursor moves. After a brief interval of no mouse movement, the transport controls are hidden. If uiMode is set to "none", no controls are displayed in full-screen mode.
Note  Displaying transport controls in full-screen mode requires the Windows XP operating system.
If transport controls are not displayed in full-screen mode, then Windows Media Player automatically exits full-screen mode when playback stops.

Examples

The following example creates a button that uses the fullScreen property to switch an embedded player object to full-screen mode. The AxWMPLib.AxWindowsMediaPlayer object is represented by the variable named player.



private void fullScreen_Click(object sender, System.EventArgs e)
{
    // If the player is playing, switch to full screen. 
    if (player.playState == WMPLib.WMPPlayState.wmppsPlaying)
    {
        player.fullScreen = true;
    }
}

What is the use of n-tier architecture and 3-tier architecture?

how to implement 3-tier architecture in asp.net using c#. 3-Tier architecture is also called layered architecture. Some people called it ...