Thursday, December 31, 2009
How To Add Border To Image Within DataGrid Column in Silverlight
<data:DataGridTemplateColumn Header="Image">
<data:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Border BorderBrush="Black" Width="101" BorderThickness="1,1,1,1" Height="13" >
<Image Width="25" Height="11" Source="http://localhost/SLR/images/pers_org.png" Stretch="UniformToFill" HorizontalAlignment="Left" Canvas.Top="0" Canvas.Left="0" >
</Image>
</Border>
</DataTemplate>
</data:DataGridTemplateColumn.CellTemplate>
</data:DataGridTemplateColumn>
//Bind the Following code within datagrid LoadingRow Event
Border border = (Border)dgName.Columns[4].GetCellContent(e.Row);// value 4 is the Possible of the Cell in the datagrid
Image image = (Image)border.Child;
//RelMang tmpRm = (RelMang)e.Row.DataContext;
//image.Width = Convert.ToDouble(tmpRm.mx_Rel_Prcntg.ToString());
image.Width = Convert.ToDouble(20); // Dynamically Setting Width of the Image Which in Datagrid Cell
Thursday, December 24, 2009
Silverlight How To Pass Values Between Pages or Forms
private string valueToPass
public string valTo
{
get
{
return valueToPass;
}
set
{
valueToPass = value;
}
}
page1.xaml.cs
App ap = (App)Application.Current;
ap.valueToPass = "YourValue";
page2.xaml.cs
App ap = (App)Application.Current;
messageBox.show(ap.valueToPass);
How To wrap Text In silverlight DataGrid Column
<data:DataGridTemplateColumn Header="Your Header" Width="150">
<data:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock TextWrapping="Wrap" Text="{Binding Your_Data_Display}" />
</DataTemplate>
</data:DataGridTemplateColumn.CellTemplate>
</data:DataGridTemplateColumn>
Wednesday, December 23, 2009
Silverlight The type or namespace name 'IValueConverter' could no
While Using Silverlight if you are getting the following Error "The type or namespace name 'IValueConverter' could not be found (are you missing a using directive or an assembly reference?)" Just Include namespace System.Windows.Data; in your code behind.
Silverlight The type or namespace name 'BitmapImage' could not be
While Using Silverlight if you are getting the following Error "The type or namespace name 'BitmapImage' could not be found (are you missing a using directive or an assembly
reference?)" Just Include namespace System.Windows.Media.Imaging; in your application
Monday, December 7, 2009
How To Pass values from iframe to Controls In parent Document
if(parent.document.Yourformname.YOurfieldname != null){
parent.document.Yourformname.YourfieldId.value = SetYourValue;
}
For Div Content
if(parent.document.all["DIVName"] != null){
parent.document.all["YourDIVName"].innerHTML = SetYourValue;
}
How to call the function with parameter in iframe
var objIFrame = document.frames["ifrmId"];
if ((objIFrame ) && (objIFrame .fnNameInIframe)) {
objIFrame .fnNameInIframe(Param1);
}
Thursday, December 3, 2009
Whats The Difference Between Manifest and Metadata
Manifest describes an assembly itself, Assembly name version number, culture, strong name, etc.
Friday, November 20, 2009
How To Find The Number Of Live Connection In Database
GROUP BY dbid
Monday, November 16, 2009
How To Duplicate Tab Or Clone Tab In Firefox
Supported By Firefox 3.x
Thursday, November 12, 2009
Regular Expression To Check Input With no space using JavaScript
<head>
<script>
function validateContent(evt)
{
var pattern = /^\w[a-zA-Z@#0-9.]*$/;
if(evt.value.search(pattern) == -1)
{
alert('Space not Allowed');
return false;
}
}
</script>
</head>
<body>
<input type='text' onkeyup='return validateContent(this);' />
</body>
</html>
Friday, October 16, 2009
How To Search Text In Script In Database In Procedure
SET @srchString='Procedure_Name'
SET @srchString = '%' + @srchString + '%'
SELECT O.NAME FROM syscomments C
JOIN sysobjects O ON O.id = C.id
WHERE O.xtype = 'P' AND C.TEXT LIKE @srchString
Wednesday, September 16, 2009
How To Set Background Image For Canvas
<Canvas.Background>
<ImageBrush ImageSource="images/dashboard.jpg" Stretch="Fill" />
</Canvas.Background>
See Also...
ImageBrush
Strech Property
Sunday, September 13, 2009
How To Send Mail With Attachment In Asp.Net
using System.Net;
using System.Net.Mail; // For Mailing Purpose
using System.IO; // To Check File existence in Server
using System.Text; // For Encoding.UTF8
try
{
MailMessage objMailMsg = new MailMessage(txtFrom.Text.Trim(), txtTo.Text.Trim());
Attachment MailAttachment;
objMailMsg.BodyEncoding = Encoding.UTF8;
if (txtCc.Text.Trim().Length > 0)
{
objMailMsg.CC.Add(txtCc.Text.Trim());
}
if (txtBcc.Text.Trim().Length > 0)
{
objMailMsg.Bcc.Add(txtBcc.Text.Trim());
}
objMailMsg.Subject = "Testing Mail";
objMailMsg.Body = txtMessage.Text.Trim();
if (fuMailAtt.HasFile)
{
if (!File.Exists(Server.MapPath(@"Attach\" + fuMailAtt.FileName)))
{
fuMailAtt.SaveAs(Server.MapPath(@"Attach\" + fuMailAtt.FileName));
MailAttachment = new Attachment(Server.MapPath(@"Attach\" + fuMailAtt.FileName));
objMailMsg.Attachments.Add(MailAttachment);
}
else
{
MailAttachment = new Attachment(Server.MapPath(@"Attach\" + fuMailAtt.FileName));
objMailMsg.Attachments.Add(MailAttachment);
}
}
objMailMsg.Priority = MailPriority.High;
objMailMsg.IsBodyHtml = true;
SmtpClient objSMTPClient = new SmtpClient("smtp.mail.yahoo.com", 587);
objSMTPClient.Credentials = new NetworkCredential("YourYahooId", "Your Yahoo Password");
objSMTPClient.Send(objMailMsg);
Response.Write("Mail Send");
}
catch (Exception ex)
{
Response.Write("Mail Not Send " + ex.Message);
}
Controls Name
From Address txtFrom
To Address txtTo
Cc Address txtCc
Bcc Address txtBcc
FileUpload fuMailAtt
Message txtMessage
Send Button btnSend
Download SourceCode
Thursday, September 10, 2009
Thursday, September 3, 2009
Tuesday, September 1, 2009
The type or namespace name 'AspNetCompatibilityRequirements' coul
Using System.ServiceModel.Activation // C#
Imports System.ServiceModel.Activation // VB
Wednesday, August 26, 2009
Friday, August 21, 2009
Whats the Difference between Cluster and Non-cluster index ?
* There can be only one Clustered index for a table
* Usually made on the primary key
* The logical order of the index matches the physical stored order of the rows on disk
Non-Clustered Index
* There can be only 249 Clustered index for a table
* Usually made on the any key
* The logical order of the index does not match the physical stored order of the rows on disk
Silverlight : How To Bring Control To Front
Thursday, August 13, 2009
How To Create Dynamic TextBox With Event Handler
{
createTxt();
}
private void createTxt()
{
TextBox txt = new TextBox();
txt.ID = "txt1";
txt.AutoPostBack = true;
txt.TextChanged += new EventHandler(txt_TextChanged);
form1.Controls.Add(txt);
}
void txt_TextChanged(object sender, EventArgs e)
{
TextBox txtBx = (TextBox)sender;
Page.Title = txtBx.Text;
}
Wednesday, August 12, 2009
JavaScript Error Handling
constructor
Specifies the function that created an instance's prototype.
message
Error message.
name
Error name.
<html>
<head>
<title>Error Handling</title>
<script language='javascript'>
window.onload = function()
{
try
{
var x = 1;
var value = x / y;
}
catch(err)
{
alert("constructor"+ ": " + err.constructor +'\r\n' + 'message'+ ": " + err.message + '\r\n' + 'name' + ": "+ err.name);
}
finally
{
alert("Finally block");
}
}
</script>
</head>
</html>
How To Detect Silverlight Installed In Client Machine
<body>
<script language="javascript">
var browser = navigator.appName;
var SLInstalled = false;
if (browser == 'Microsoft Internet Explorer')
{
try
{
var slControl = new ActiveXObject('AgControl.AgControl');//IE
SLInstalled = true;
}
catch (e)
{
SLInstalled = false;
}
}
else
{
try
{
if (navigator.plugins["Silverlight Plug-In"]) // Other Than IE
{
SLInstalled = true;
}
}
catch (e)
{
SLInstalled = false;
}
}
if(SLInstalled == true)
{
alert('Silverlight Installed');
}
else
{
alert('Silverlight Not Installed');
}
</script>
</body>
</html>
Tuesday, August 11, 2009
How To Triggers Event In Silverlight
using System.Windows.Automation.Peers;
using System.Windows.Automation.Provider;
ButtonAutomationPeer buttonAutoPeer = new ButtonAutomationPeer(YourButtonName);
IInvokeProvider invokeProvider = buttonAutoPeer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;
invokeProvider.Invoke();
Monday, August 10, 2009
How To Get Storyboard Current Status
StoryboardName.GetCurrentState
GetCurrentState Method enumeration values are
Active - The current animation changes in direct relation to that of its parent.
Filling - The animation continues and does not change in relation to that of its parent.
Stopped - The animation is stopped.
What's the difference between a member variable, and a local variable?
class MoterVehicle{
String licensePlate = ""; // member variable
double speed; = 0.0; // member variable
double maxSpeed; = 123.45; // member variable
boolean isSpeeding() {
double excess; // local variable
excess = this.maxSpeed - this.speed;
if (excess < 0) return true;
else return false;
}
}
Monday, August 3, 2009
How To Hide Legend In PieChar Silverlight
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
xmlns:datavis="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit"
xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="White">
<charting:Chart Title="Legend Disabled">
<charting:Chart.LegendStyle>
<Style TargetType="datavis:Legend">
<Setter Property="Width" Value="0"/>
<Setter Property="Height" Value="0"/>
</Style>
</charting:Chart.LegendStyle>
<charting:Chart.Series>
<charting:PieSeries DependentValuePath="X" >
<charting:PieSeries.ItemsSource>
<PointCollection>
<Point X="1"/>
<Point X="2"/>
<Point X="3"/>
<Point X="4"/>
</PointCollection>
</charting:PieSeries.ItemsSource>
</charting:PieSeries>
</charting:Chart.Series>
</charting:Chart>
</Grid>
</UserControl>
Friday, July 31, 2009
Silverlignt How To Get The Cell Content Of The DataGrid When AutoGenerateColumns Set True
{
TextBlock tb = dg.Columns[0].GetCellContent(e.AddedItems[0]) as TextBlock;
//tb.text will hold the Column Content
}
Wednesday, July 29, 2009
Create GIF Animations Online
Getting AG_E_PARSER_BAD_PROPERTY_VALUE Error
How To Change the start page Silverlight XAML
app.xaml.cs
private void Application_Startup(object sender, StartupEventArgs e)
{
// this.RootVisual = new Page(); // Default
this.RootVisual = new UserDefinedXaml(); // Changed Xaml, if u add UserDefinedXaml.xaml to your project.
}
app.xaml.vb
Private Sub Application_Startup(ByVal o As Object, ByVal e As StartupEventArgs) Handles Me.Startup
Me.RootVisual = New UserDefinedXaml()
End Sub
Tuesday, July 28, 2009
Monday, July 27, 2009
how to get The Business Dates between the two given dates
(@STARTDATE datetime,@EntDt datetime)
RETURNS TABLE
AS
RETURN
with DateList as
(
select cast(@STARTDATE as datetime) DateValue
union all
select DateValue + 1 from DateList
where DateValue + 1 < convert(VARCHAR(15),@EntDt,101)
)select * from DateList where DATENAME(WEEKDAY, DateValue ) not IN ( 'Saturday','Sunday' )
GO
select * from dbo.fnGetNoOfBusinessDates(getdate(),getdate()+30);
Friday, July 24, 2009
how to get number of business days between two given dates
CREATE FUNCTION dbo.fnGetNoOfBusinessDays(@STARTDATE datetime,@EntDt datetime)
returns int
as
BEGIN
declare @dtCnt int;
;with DateList as
(
select cast(@STARTDATE as datetime) DateValue
union all
select DateValue + 1 from DateList
where DateValue + 1 < convert(VARCHAR(15),@EntDt,101)
)
select @dtCnt = count(*) from DateList where DATENAME(WEEKDAY, DateValue ) not IN ( 'Saturday','Sunday' )
return @dtCnt
END
go
select dbo.fnGetNoOfBusinessDays(getdate(),getdate()+50) as NoOfBusinessDays
Thursday, July 23, 2009
What's the difference between Dataset.clone and Dataset.copy ?
Copy :- Copies both Structure and data
Boxing & UnBoxing
Example:
class Test
{
static void Main() {
int i = 1;
object o = i; // boxing
int j = (int) o; // unboxing
}
}
Tuesday, July 21, 2009
SQL Azure
As a part of the Windows Azure platform, SQL Azure Database will deliver traditional relational database service in the cloud, supporting T-SQL over Tabular Data Stream (TDS) protocol. SQL Azure Database will be available in two editions: the Web Edition Database and the Business Edition Database.
Web Edition – 2GB of T-SQL based database space for $9.99 per month
Business Edition – 10GB of T-SQL based database space for $99.99 per month.
Customers can also purchase bandwidth for $.10 in and $.15 out per GB
SQL Azure Database is on track to deliver a public CTP in August and ship in the second half of calendar year 2009. In its initial release, SQL Azure Database will support relational capabilities suitable for relational apps, including multi-tenant apps requiring large levels of scale. Future releases of SQL Azure will support advanced features like distributed queries across partitions, and auto-partition. Developers will be able to utilize existing Transact-SQL code to access their data in the cloud.
Read More About SQL Azure.
Reference : Pinal Dave (blog.SQLAuthority.com)
Monday, July 20, 2009
whats the Difference between Page.RegisterClientScriptBlock and Page.RegisterStartupScript
element. Form elements at this stage are not instantiated, so the code cannot access the form elements.
The RegisterStartupScript method inserts the specified client-side script just before the closing tag of the Page object's
element. Form elements at this stage are instantiated, so the code can access the form elements.
Thursday, July 16, 2009
Google Services At a Glance
GButts Display all of your Google Services as buttons just next to your addressbar or anywhere you like it!
Download Firefox GButts Extension
Wednesday, July 15, 2009
How To Set Textbox first letter in caps
Output
Tuesday, July 14, 2009
How To Parse Url Query String Using JavaScript
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexStr = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexStr );
var results = regex.exec(window.location.href);
if( results == null )
return "";
else
return results[1];
}
How To call = alert(parseUrl(QryStringParameterName));
Example Click Here
Retrieve Content From Web Page - Screen Scraping
private string GetPageContent(string url)
{
string src = string.Empty;
try
{
WebClient client = new WebClient();
UTF8Encoding encoding = new UTF8Encoding();
src = encoding.GetString(client.DownloadData(url));
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
return src;
}
Close Window from CodeBehind
When we can declare a column as Unique and Not Null both at the same time. What is the use Primary Key then?
1)unique key can be null but Primary key cant be null.
2)primary key can be referenced to other table as Foreign Key.
3)we can have multiple unique key in a table but PK is one and only one.
4) Primary key in itself is unique key.
5) Primary key which allows only unique+not null values,where has unique allow unique and null values because a null value is not equal to a null value
Monday, July 13, 2009
How To Delete Browser Page Cache
Response.Cache.SetNoServerCaching();
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
Response.Cache.SetExpires(new DateTime(1900, 01, 01, 00, 00, 00, 00));
Friday, July 10, 2009
Check Your Website Search Ranking
ASP.NET Page Life Cycle Overview
Page Request
Start
Page Initialization
Load
Validation
Postback Event Handling
Rendering
Unload
Life-cycle Events
PreInit
Init
InitComplete
PreLoad
Load
ControlEvent
LoadComplete
PreRender
SaveStateComplete
Render
Unload
Thursday, July 9, 2009
What is the difference between Convert.ToInt32 and Int32.Parse
{
Convert.ToInt32(string) AND Int32.Parse(string) Yield Identical Results;
}
else
{
Int32.Parse(null) throws an ArgumentNullException;
Convert.ToInt32(null) returns a zero;
}
How To Do Case Insensitive String Comparison
{
Response.Write("Equal");
}
else
{
Response.Write("!Equal");
}
Wednesday, July 8, 2009
Whats The Difference Between string and stringbuilder
Strings are immutable and they are actually returning a modified copy of the string.
StringBuilder
Strings are mutable there object as a buffer that can contain a string with the ability to grow from zero characters to the buffer's current capacity. Until you exceed that capacity, the string is assembled in the buffer and no object is allocated or released. If the string becomes longer than the current capacity, the StringBuilder object transparently creates a larger buffer. The default buffer initially contains 16 characters
Google Apps is out of beta (yes, really)
Tuesday, July 7, 2009
How To Get IP Address
<html>
<head>
<title>WMI Scripting HTML</title>
<script FOR="foo" EVENT="OnCompleted(hResult,pErrorObject, pAsyncContext)" LANGUAGE="JScript">
document.getElementById('divMACAddr').innerHTML='Machine Number :'+unescape(vMACAddr);
document.getElementById('divIPAddr').innerHTML='IP Address :'+unescape(vIPAddr);
document.getElementById('divDNSName').innerHTML='DNS Name '+unescape(vDNSName);
</script>
<script FOR="foo" EVENT="OnObjectReady(objObject,objAsyncContext)" LANGUAGE="JScript">
if(objObject.IPEnabled != null && objObject.IPEnabled != "undefined" && objObject.IPEnabled == true)
{
if(objObject.MACAddress != null && objObject.MACAddress != "undefined")
vMACAddr = objObject.MACAddress;
if(objObject.IPEnabled && objObject.IPAddress(0) != null && objObject.IPAddress(0) != "undefined")
vIPAddr = objObject.IPAddress(0);
if(objObject.DNSHostName != null && objObject.DNSHostName != "undefined")
vDNSName = objObject.DNSHostName;
}
</script>
</head>
<body>
<object classid="CLSID:76A64158-CB41-11D1-8B02-00600806D9B6" id="locator" VIEWASTEXT></object>
<object classid="CLSID:75718C9A-F029-11d1-A1AC-00C04FB6C223" id="foo"></object>
<script LANGUAGE="JScript">
var service = locator.ConnectServer();
var vMACAddr ;
var vIPAddr ;
var vDNSName;
service.Security_.ImpersonationLevel=3;
service.InstancesOfAsync(foo, 'Win32_NetworkAdapterConfiguration');
</script>
<form method="POST" action="NICPost.asp" id="formfoo" name="formbar">
<div id="divMACAddr"></div>
<div id="divIPAddr"></div>
<div id="divDNSName"></div>
</form>
</body>
</html>
Note:ActiveX to be Enabled, It Will Prompt to Get User To allow or not allow(IE )
Vizerra- 3D Virtual Models of World Heritage Sites
is a unique software, which allows us to visit all the most beautiful
places in the world!,we can surf the highest quality 3D copies of these sites,
listen to audio guides, read their detailed descriptions provided by reputable
Publishers and Museums, or use a full-functional map service. And all this in
just one application!they give us a chance to travel around the globe right from
your personal computer and for absolutely free of charge.Vizerra is the first world’s first 3D educational portal which enable its users to
travel to different historic locations Old Town Square, Macchu Picchu and Angkor
Vat directly from your computer. This software is useful for those lazy guys and girls
who are curious but do not want to spend their money on traveling to particular
destination.Besides offering high quality 3D copies of these sites, it also provides audio
guides with detailed description made by reputable publishers and museums.
(Source Vizerra)
Icon Finder - Find the prefect Icon for WebPages
Icon finder is an icon search engine, which can allow us to find prefect icons for webpages. All you need to do is just search for the icon you needed to you, the image can be download in 2 formats(PNG,ICO).You can use these icons as favicon icon and add them to your webpages. You can also customize the background of these icons.They have 159 icon sets. You can search them via browsing iconfinder.net.
Friday, July 3, 2009
How To Find Position Of An HTML element
var curPos = 0;
try {
switch(Cord)
{
case 'X':
case 'Y':
if (Obj.offsetParent)
{
while (1)
{
if(Cord == 'X'){
curPos += Obj.offsetLeft;
}else{
curPos += Obj.offsetTop;
}
if (!Obj.offsetParent) break; Obj = Obj.offsetParent;
}
}
else
{
if(Cord == 'X'){
if (Obj.x)curPos += Obj.x;
}
else{
if(Obj.y)curPos += Obj.y;
}
}
break;
}
}
catch (e) {
document.write('An exception occurred.');
}
finally {
return curPos;
}
}
function callfn(Cord, func, obj) {
return func(Cord, obj);
}
//way of Calling Function
"alert(callfn('X',GetPos,document.getElementById('elementId')))" // X co-ordinates
"alert(callfn('Y',GetPos,document.getElementById('elementId')))" // Y co-ordinates
Generate Random Number and Character JavaScript
var chars = null;
var string_length = len;
try {
switch (mode) {
case 'U':
chars = "ABCDEFGHIJKLMNOPQRSTUVWXTZ";
break;
case 'L':
chars = "abcdefghiklmnopqrstuvwxyz";
break;
case 'N':
chars = "0123456789";
break;
case 'UN':
chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ";
break;
case 'LN':
chars = "0123456789abcdefghiklmnopqrstuvwxyz";
break;
case 'Mix':
chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
break;
default: chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
}
var randomstring = '';
for (var i = 0; i < string_length; i++) {
var rnum = Math.floor(Math.random() * chars.length);
randomstring += chars.substring(rnum, rnum + 1);
}
}
catch (e) {
document.write('An exception occurred.');
}
finally {
return randomstring;
}
}
function callGenfn(mode, func, length) {
return func(mode, length);
}
//callGenfn(Mode,FunctionName,length)
alert(callGenfn('N', GenChar,6));
alert(callGenfn('U', GenChar,6));
alert(callGenfn('L', GenChar,6));
alert(callGenfn('UN', GenChar,6));
alert(callGenfn('LN', GenChar,6));
alert(callGenfn('Mix', GenChar,6));
Thursday, July 2, 2009
Firefox 3.5
What’s New in Firefox 3.5:
Firefox 3.5 makes surfing the Web easier and more enjoyable with
exciting new features and platform updates that allow Web developers to
create the next generation of Web content. Native support for open
video and audio, private browsing, and support for the newest Web
technologies will enable richer, more interactive online experiences.
- Performance.
- Open Video and Audio.
- Privacy Controls.
- Location Aware Browsing. more....
Wednesday, July 1, 2009
How to get browser width and height
<head>
<title>Get Browser Width & Height</title>
<script languuage='javascript'>
var BWidth,BHeigth;
function fn() {
if (typeof window.innerWidth != 'undefined') { // For (mozilla/netscape/opera/IE7)
BWidth = window.innerWidth;
BHeigth = window.innerHeight;
}
else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' &&
document.documentElement.clientWidth != 0) { // For (IE 6 with proper doctype)
BWidth = document.documentElement.clientWidth;
BHeigth = document.documentElement.clientHeight;
}
else { //For (IE < 6)
BWidth = document.getElementsByTagName('body')[0].clientWidth,
BHeigth = document.getElementsByTagName('body')[0].clientHeight
}
document.title = 'Your Browser width is ' + BWidth + ' Height is' + BHeigth;
}
</script>
</head>
<body onresize='fn()'>
<h3>See The Page Title While Resizing the Page (Width & Height Will Be Changing</h3>
</body>
</html>
Thursday, June 25, 2009
How to convert string to int
// This method Converts the string representation of a number to its 32-bit signed integer equivalent,it return whether conversion succeeded or not
int num;
string[] value = { "123", "test", "-123" };
for (int i = 0; i < value.Length - 1; i++)
{
bool result = Int32.TryParse(value[i].ToString(), out num);
if (result)
{
Response.Write("String " + value[i].ToString() + " Converted Successfully");
}
else
{
if (value[i] == null) value[i] = "";
Response.Write("Attempted For " + value[i] + " failed.");
}
}
Wednesday, June 24, 2009
Microsoft Release Antivirus
No cost, no hassle security software for your Home PC. Microsoft
Security Essentials (formerly known as Microsoft "Morro") is designed to occupy less
space and supports Windows XP,Windows Vista, and the upcoming Windows 7 operating-
system. The new Microsoft free antivirus gives full protection from Viruses, Spyware,
Rootkits, and Trojans, similar to other paid enterprises antivirus software.Visit
Microsoft Connect to download the Beta,How to manually download the latest definition
updates for Microsoft Security Essentials
window.onload firefox,IE
<head>
<script language='javascript'>
var browserName = navigator.appName;
if (browserName == "Microsoft Internet Explorer") {
window.onload = function(){alert('IE Onload');}
}
else {
if (document.addEventListener){
document.addEventListener("DOMContentLoaded", function(){alert('Firefox Onload');}, false);
}
}
</script>
</head>
<body>
replacement for window.onload in Firefox
</body>
</html>
Wednesday, June 10, 2009
How To Create Row Dynamically And Remove Row - JavaScript
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head2" >
<title>Dynamically Create Table Row And Remove Row</title>
<script type="text/javascript" language="javascript">
function addRow() {
var tbl = document.getElementById('evntTbl');
var lstRow = tbl.rows.length;
var iteration = lstRow;
if (lstRow <= 10) {
var row = tbl.insertRow(lstRow);
var cellLeft = row.insertCell(0);
var el0 = document.createElement('input');
el0.type = 'text';
el0.name = 'txtName_' + iteration;
el0.id = 'txtName_' + iteration;
//el0.size = 40;
el0.style.width = 170 + 'px';
cellLeft.appendChild(el0);
var cellMid = row.insertCell(1);
var el1 = document.createElement('input');
el1.type = 'text';
el1.name = 'txtRole_' + iteration;
el1.id = 'txtRole_' + iteration;
//el1.size = 40;
el1.style.width = 170 + 'px';
cellMid.appendChild(el1);
var cellRight = row.insertCell(2);
var el2 = document.createElement('input');
el2.type = 'text';
el2.name = 'txtEmail_' + iteration;
el2.id = 'txtEmail_' + iteration;
//el2.size = 40;
el2.style.width = 170 + 'px';
cellRight.appendChild(el2);
var cellImg = row.insertCell(3);
var el3 = document.createElement("button");
el3.id = 'btn_' + iteration;
el3.style.zIndex = 200;
el3.style.cursor = 'hand';
el3.value = '-';
el3.onclick = function() { removeRow(this); };
cellImg.appendChild(el3);
}
else {
document.getElementById('btnAdd').disabled=true;
}
if (document.getElementById('txtName_' + (iteration)) != null) {
document.getElementById('txtName_' + (iteration)).focus();
}
}
function removeRow(evt) {
var tbl = document.getElementById('evntTbl');
var lstRw = tbl.rows.length;
if(lstRw <= 10)
{
document.getElementById('btnAdd').disabled=false;
}
var _row = evt.parentNode.parentNode;
_row.parentNode.deleteRow(_row.rowIndex);
}
</script>
</head>
<body>
<div>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" valign="top" style="height: 5px">
</td>
</tr>
<tr>
<td align="right" class="style31">
</td>
<td align="left">
<table width="60%" border="0" cellpadding="2" cellspacing="2" id='evntTbl'>
<tr>
<td width="10%" align="left" class="style31">
Column 1
</td>
<td width="10%" align="left" class="style31">
Column 2
</td>
<td width="10%" align="left" class="style31">
Column 3
</td>
<td width="1%" align="left" class="style31">
</td>
</tr>
<tr>
<td align="left" class="style31">
<input type="text" class="style5" tabindex="6" id="Text1" maxlength="25" title=""
style="width: 170px" />
</td>
<td align="left" class="style31">
<input type="text" class="style5" tabindex="7" id="Text2" maxlength="25" title=""
style="width: 170px" />
</td>
<td align="left" class="style31">
<input type="text" class="style5" tabindex="8" id="Text3" maxlength="25" title=""
style="width: 170px" />
</td>
<td width="1%" align="left" class="style31">
<input type='button' id='btnAdd' value='+' style="cursor: hand;" tabindex="9" onclick="addRow();" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</body>
</html>
Download File
Friday, May 15, 2009
Silverlight How to Convert String to Thickness
res = new Thickness(Convert.ToDouble(e.GetPosition(null).Y.ToString()));
By Default e.GetPosition(null).Y is Double datatype for example i convert that into string and again convert that to Double
Thursday, April 30, 2009
How to clear all the text field
var txtField = document.getElementsByTagName('input')
for (var i_tem = 0; i_tem < txtField.length; i_tem++)
if (txtField[i_tem].type == 'text')
txtField[i_tem].value = ''
}
Monday, April 27, 2009
Get Mouse Pointer Position
<body>
<form>
<div id="divX" > X</div>
<div id="divY" > Y</div>
</form>
<script language="JavaScript">
<!--
var IE = document.all?true:false
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getXY;
var tmpX = 0
var tmpY = 0
function getXY(e) {
if (IE) {
tmpX = event.clientX + document.body.scrollLeft
tmpY = event.clientY + document.body.scrollTop
} else {
tmpX = e.pageX
tmpY = e.pageY
}
if (tmpX < 0){tmpX = 0}
if (tmpY < 0){tmpY = 0}
document.getElementById('divX').innerHTML = tmpX;
document.getElementById('divY').innerHTML = tmpY;
return true
}
//-->
</script>
</body>
</html>
Saturday, April 25, 2009
how to encrypted connection string in web.config
using System.Configuration;
using System.Web.Configuration;
Encrypt
Configuration Myconfig = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
ConfigurationSection section = Myconfig .GetSection("connectionStrings");
if (!section.SectionInformation.IsProtected)
{
section.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider");
Myconfig .Save();
}
Decrypt
Configuration Myconfig = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
ConfigurationSection section = Myconfig .GetSection("connectionStrings");
if (section.SectionInformation.IsProtected)
{
section.SectionInformation.UnprotectSection();
Myconfig .Save();
}
Note
once the data is encrypted, when it's read from an ASP.NET page (i.e., reading the connection string
information from a SqlDataSource control or programmatically, via ConfigurationManager.ConnectionStrings[connStringName].ConnectionString),
ASP.NET automatically decrypts the connection string and returns the plain-text value.
Friday, April 24, 2009
List all drivers (Client Machine)
<HTML>
<HEAD>
<SCRIPT language=JavaScript>
//This function returns the drive list from client system
function getDriveList() {
var objfs, s, n, e, x;
objfs = new ActiveXObject("Scripting.FileSystemObject");
e = new Enumerator(objfs.Drives);
s = "";
do {
x = e.item();
s = s + x.DriveLetter;
s += ": ";
if (x.DriveType == 3) n = x.ShareName;
else if (x.IsReady) n = x.VolumeName;
else n = "<font color=red>[Other Drive-not intialized]</font>";
s += n + "<br>";
e.moveNext();
} while (!e.atEnd());
return (s);
}
</SCRIPT>
</HEAD>
<BODY>
<h5>Available drives on Client system:</h5>
<SCRIPT language=JavaScript> document.write(getDriveList());</SCRIPT>
</BODY>
</HTML>
It Works in IE Only.
Monday, April 20, 2009
how to validate textbox value (Date Format)
<head>
<script language="javascript">
function checkDt(dtVal) {
var mo, day, yr;
var entry = dtVal.value;
var reLong = /\b\d{1,2}[\/-]\d{1,2}[\/-]\d{4}\b/;
var reShort = /\b\d{1,2}[\/-]\d{1,2}[\/-]\d{2}\b/;
var valid = (reLong.test(entry)) || (reShort.test(entry));
if (valid) {
var delimChar = (entry.indexOf("/") != -1) ? "/" : "-";
var delim1 = entry.indexOf(delimChar);
var delim2 = entry.lastIndexOf(delimChar);
mo = parseInt(entry.substring(0, delim1), 10);
day = parseInt(entry.substring(delim1+1, delim2), 10);
yr = parseInt(entry.substring(delim2+1), 10);
// two-digit of year
if (yr < 100) {
var today = new Date();
// get floor of current century
var currCent = parseInt(today.getFullYear() / 100) * 100;
// two digits up to this year + 15 expands to current century
var threshold = (today.getFullYear() + 15) - currCent;
if (yr > threshold) {
yr += currCent - 100;
} else {
yr += currCent;
}
}
var testDate = new Date(yr, mo-1, day);
if (testDate.getDate() == day) {
if (testDate.getMonth() + 1 == mo) {
if (testDate.getFullYear() == yr) {
dtVal.value = mo + "/" + day + "/" + yr;
return true;
} else {
alert("Check the year entry.");
}
} else {
alert("Check the month entry.");
}
} else {
alert("Check the date entry.");
}
} else {
alert("Invalid date format. Enter as mm/dd/yyyy.");
}
return false;
}
</script>
</head>
<body>
<input type="text" id="txtDt" onblur="checkDt(this)" />
</body>
how to make a page not to get cached
HttpContext.Current.Response.Cache.SetNoStore();
Friday, April 10, 2009
How To Set Vertical Scroll For the Particular Page
{
document.body.scroll = "yes";
}
Note:IE Supported
Tuesday, March 31, 2009
how to find the list of stored procedure in the database
Sql Server 2005
SELECT * FROM sys.procedures;
User Procedure
SELECT * from sys.objects where type='p' and is_ms_shipped=0 and [name] not like 'sp[_]%diagram%';
Friday, March 20, 2009
Friday, March 13, 2009
Thursday, March 12, 2009
Wednesday, February 25, 2009
how to trigger dropdown onchange event using javascript
document.forms[0].elements['dropdownid'].onchange();
Tuesday, February 17, 2009
Tuesday, February 3, 2009
How to check whether Internet connection is avaialable or not
using System.Net;
WebRequest objWebReq;
WebResponse objResp;
public Boolean IsConnectionAvailable()
{
System.Uri objUrl = new System.Uri("http://www.google.com/");
objWebReq = WebRequest.Create(objUrl);
try
{
objResp = objWebReq.GetResponse();
objResp.Close();
objWebReq = null;
return true;
}
catch (Exception ex)
{
objResp.Close();
objWebReq = null;
return false;
}
}
Sunday, January 18, 2009
How to change the color of the selected item of drop downlist
<html>
<head>
<title>
change the color of the selected item
</title>
<script language="javascript">
function chgColor(evt)
{
evt.options[evt.selectedIndex].style.background = 'red';
for(i=0; i< evt.options.length;i++)
{
if(i != evt.selectedIndex)
{
evt.options[i].style.background = '';
}
}
}
</script>
</head>
<body>
<select onchange="chgColor(this)">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="1">5</option>
<option value="2">6</option>
<option value="3">7</option>
<option value="4">8</option>
<option value="1">9</option>
<option value="2">0</option>
</select>
</body>