Showing posts with label Javascript. Show all posts
Showing posts with label Javascript. Show all posts

Sunday, October 25, 2009

Open a New Window On Server Side using Javascript Code in Asp.net

· 1 comments

// open new window with specified path

function OpenWindow(url)

{
newwindow = window.open(url, 'mywindow', 'width=500,height=400');

}

Now In .aspx.cs page or server side to use the javascript window open you have to use the following code

StringBuilder popupScript = new StringBuilder();
popupScript.Append("");
// if you are using script manager - update panel then this
ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "PopupScript", popupScript.ToString(), false);
//else
Page.RegisterStartupScript("PopupScript", popupScript.ToString());

Read More......

Monday, August 31, 2009

Textbox Watermark using Ajaxtoolkit or By Javascript

· 0 comments

Adding Watermark to textbox can be done in two ways:

1) Using Ajax Toolkit:

<asp:TextBox runat="server" id="txtname"/>
<ajaxToolkit:TextBoxWatermarkExtender ID="TBWE2" runat="server"
TargetControlID="TextBox1"
WatermarkText="Type First Name Here"
WatermarkCssClass="watermarked" />

For more information on Ajax Toolkit please visit:
http://www.asp.net/ajax/

2) Using Javascript
:

<asp:TextBox ID=”txtname” runat=”server” Text = “Please Enter your Name here”
onblur = “TextboxWaterMark(this, event);”
onfocus = “TextboxWaterMark(this, event);”>
</asp:TextBox>

<script type = “text/javascript”>
var Text = “Please Enter your text here”;//black

function TextboxWaterMark(txtid, evnt)
{
if(txtid.value.length == 0 && evnt.type == “blur”)
{
txtid.style.color = “set the color you want”;//red
txtid.value = Text;
}
if(txtid.value == Text && evnt.type == “focus”)
{
txtid.style.color = “set the color you want”;
txtid.value=”";
}
}
</script>

To use in code behind :

txtname.Attributes.Add(”onblur”, “TextboxWaterMark(this, event);”);

txtname.Attributes.Add(”onfocus”, “TextboxWaterMark(this, event);”);

Read More......

Sunday, May 31, 2009

Download Cheatsheets - .Net, Sql Server, Php, Regular Expressions, CSS, Ajax,Javascript....

· 0 comments

A cheat sheet or crib sheet is a concise set of notes used for quick reference.

You can download cheatsheets of various technologies like:

.Net

Actionscript

Ajax

Javascript

C#

HTML

Sql Server

CSS

JAVA

PHP

Regular Expressions

MySql

Asp/Vbscript

etc..

from

http://www.addedbytes.com/cheat-sheets/

http://www.cheat-sheets.org/

Read More......

Saturday, March 7, 2009

Get TextBox, RadioButtonList, DropDownList, CheckBoxes through JavaScript.

· 0 comments

In this article refers how to get value from asp.net controls like TextBox, RadioButtonList, DropDownList, CheckBoxes through JavaScript.

http://www.dotnetfunda.com/articles/article72.aspx

Read More......