Monday, September 28, 2009

Captcha ASP.NET 2.0 Server Control

Captcha control is used to validate user in terms of avoiding spamming on message or comments or registration or so on . implement Captcha on your application , below are the steps how u can do that

Installation instruction:

1. Unzip the downloaded file.
2. Copy MSCaptcha.dll and MSCaptcha.xml files to your /bin application directory.
3. add reference to mscaptcha.dll file.
4. Modify your web.config file, by adding this line to &l;httphandlers> section:
<add verb="GET" path="CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha"/>

5.Add MSCaptcha control to your Visual Studio toolbox (optional)


how to use on Page

1. Add line to your .aspx file:
<%@ Register Assembly="MSCaptcha" Namespace="MSCaptcha" TagPrefix="cc1" % >

2. add the control whenever you want:

<cc1:CaptchaControl ID="ccJoin" runat="server" CaptchaBackgroundNoise="none" CaptchaLength="5" CaptchaHeight="60" CaptchaWidth="200" CaptchaLineNoise="None" CaptchaMinTimeout="5" CaptchaMaxTimeout="240" / >


3. Add this on your CS file to check or Validate enter captcha is right or wrong


ccJoin.ValidateCaptcha(txtCap.Text);
if (!ccJoin.UserValidated)
{
//Inform user that his input was wrong ...
return;
}



now its look like this way :



Download Here..


Captcha ASP.NET 2.0

Friday, September 25, 2009

css techniques

on web application CSS is playing very important role . And it is being used more and more often. Cascading Style Sheets has many advantages
like layout, design of the page,presented on the page and so on

here i have some collections of stuffs on CSS technique .



1.

Drop Cap – Capital Letters with CSS


2.

Define Image Opacity with CSS


3.

How to Create a Block Hover Effect for a List of Links


4.

Pullquotes with CSS


5.

CSS Diagrams


6.

Footer Stick


7.

CSS Image Map


8.

CSS Image Pop-Up


9.

CSS Image Replacement for Buttons
10.

Link Thumbnail


11.

CSS Map Pop


12.

PHP-based CSS Style Switcher


13.

CSS Unordered List Calender
14.

CSS-Based Tables: Techniques


15.

Printing Web-Documents and CSS




look at here more

System.IndexOutOfRangeException was unhandled (Message="Index was outside the bounds of the array.")

on C# or vb.net we are using array,Array is one of the best way to mentain collection of data together and proper way ,

here is one Error which get call whenever some problem with size and all

The exception that is thrown when an attempt is made to access an element of an array with an index that is outside the bounds of the array. This class cannot be
inherited.

.NET arrays have base 0 and should be kept in mind when coding.


ones you got this error you have to resize your array size, accroding to your requirements

Wednesday, September 23, 2009

CSV to XML Conversion using LINQ

on C#, if we want to Convert CSV to XML then you can use Language Integrated Query (LINQ) can be used to convert a CSV file to XML. Here is the sample CSV file that needs to be converted

below example code reads the CSV file to an array. LINQ is used to loop through the array and the contents are written as XML using XElement (System.XML.Linq).


public void ConvCSVToXML()

{

String[] FileContent = File.ReadAllLines(@"D:\Proj\jquery.csv");

String XMLNS = "";

XElement Inv = new XElement("type", from

items in FileContent

let fields = items.Split(',')

select new XElement("fadein",

new XElement("Tab", fields[0]),

new XElement("ProgressBar", fields[1]),

new XElement("ToolTip", fields[2]),

new XElement("Menu", fields[3]),

)
);

File.WriteAllText(@"D:\Proj\jquery.xml", XMLNS + Inv.ToString() );
}


using this you can convert your CSV file xml using C# and C# Convert CSV To XML, .NET CSV To XML

Tuesday, September 22, 2009

How to get the Upper Bound of an Array in C#

hi, if you'r using asp, vbscript and all then you have option call UBound
which will return a UpperBound value of Array. but on C#, you dont have that option call Ubound ,for that you can use GetUpperBound() option - Gets the upper bound of the specified dimension in the Array.

here is an Example which can show how to use GetUpperBound()


For i = MyArray.GetLowerBound(0) To MyArray.GetUpperBound(0)

Next i


like this way you can use both option call GetLowerBound & GetUpperBound ,
GetLowerBound will return lower bound value.here you have to pass (int value)
0 - 1st arrayvalue, 1- 2ndarrayvalue like that,

thank you.

Saturday, September 19, 2009

Download data using FTP or HTTP with C#

If you want to download data via FTP or HTTP then you can use this solution. you can Use the System.Net.WebClient to achieve this. The URI determines whether a file (file://) , FTP (FTP://) or HTTP (HTTP:// or HTTPS://) scheme is to be used.

On .Net2.0 there is an Async Version get added which will allows you download data asynchronously as a background task using its own thread from the thread pool. WebClient object can handle one async download at a time. its not useful for downloading many files concurrently , but if you want to do this then you can use multiple WebClient objects. if you want to Cancel the current download using CancelAsync.

There are Several Methods:

1. OpenRead - returns a System.IO.Stream
OpenReadAsync - async downloading use the handler OpenReadCompleted

2. DownloadData - returns a ByteArray
DownloadDataAsync - use handler DownloadDataCompleted

3. DownloadFile - Saves to a local file
DownloadFileAsync - use handler DownloadFileCompleted

4. DownloadString - returns a String ( introduced in .net 2.0)
DownloadStringAsync - use handler DownloadStringCompleted


Here is Sample code:

using System.IO;
using System.Net;
using System.Text.RegularExpressions;

string remoteUri = "http://www.entersitenamehere.com";
WebClient client = new WebClient();
string str = client.DownloadString(remoteUri);


** if you are using proxy then you need extra code to code around it.
on my next post i will tell you how you can download data using Proxy.
Downloading data over FTP, Downloading data over HTTP, FTP, HTTP, Net.WebClient

Friday, September 18, 2009

JQuery Plugins and Demos for Developers.

hello ,i have again come up with some collection of jquery plugins with Demos , hope u like it.

1. jGoogle
jGoogle will wrap google AJAX search APIs in a single jQuery plugin to extract usable data.
on the first version they have included GImageSearch option
- View demo
- View Source


2. Virtual jQuery Keyboard
jquery Virtual Keyboard is one of the good feature for preventing keystrokes , it will very dangerous when you enter some bank account and password like information , virtual keyboard will play very imp role here, you can't get the stoke on your log ,
-View Demo

3. Scrolling with Load Effects.
when we have lots of content then its not looking good when we are showing them in one and too long panel, instead of that we can show loading effects the it also look beautiful and cool
- View demo

4. Tablesorter 2.0
When we showing the records on table then sorting is one of the basic option , to show the records like date wise , increasing decrease order and so on like this feature you can add here
- View demo

5. jQuery Right-click Plugin
This plugin enable you to detect the event when user get click right button of mouse . so as per the click you can do your operation like disable the right click and so on or adding any information to drop down when clicking right click
-View demo

6. Jquery: Progress Bar
Progress bar is one of the cool feature that use can use anywhere where you are data get retrieve from database and if it will take too much time to load that page , in this case you can show loading like Effects so user can understand that page is being lead
- view Demo


7. jQuery Feed Menus
Feed is used for bookmarking and all other purpose , you can show multiple feed under one category , so you can use your space and its also look nice
- view Demo

8. gShuffle
The plugin animation is triggered every time the Shuffle button is clicked. Each time, the code will choose two squares to switch positions with one another.
- view Demo

9 -Mark It Up
MarkItUp, you can convert text areas into powerful HTML, BBCode or Wiki editor.

----
hope you like it ,
will add more on it, if you found anything could be related with this plz add on comments

Friday, September 11, 2009

Jquery ToolTip

Tooltip is one of the Cool & useful feature in Jquery , its mostly used for showing
Additional information for that records , you can use that anywhere like showing Customer information, Suggestion for form fillup , for zoom image and many more

here are some collection of tooltips .

1. Bottom slide tooltip

2. jQuery Tooltip Plugin

3.jTip

4.SimpleTip

5.BoxOver Tooltip

6.qTip

7.EZPZ jQuery Tooltip

8. CSS Globe jQuery Tooltip plugin


hope u like it

Thursday, September 10, 2009

SQL : Count String Occurrence

in SQl server, we dont have any function which can return the number of words in a perticular string .but from small tricks we can do that . now Consider here we can separating the character on space basis

example :


declare @Str VARCHAR(2000)
SET @Str = 'Hi this is Test line which count no of spaces.'
select LEN(@Str) - LEN(Replace(@Str,' ', '')) + 1


Above query will return value 10 , but if the words are separate by more than one space then it will aslo count that space. but its wrong as per the answer.
in that case Create one function which can keep multiple spaces as a single space and return proper result

Below is a Function which can remove white space and all and retrun peoper result.

CREATE FUNCTION [dbo].[WordCount] ( @inStr VARCHAR(4000) )
RETURNS INT
AS
BEGIN

DECLARE @Index INT
DECLARE @Char CHAR(1)
DECLARE @PrevChar CHAR(1)
DECLARE @WordCount INT

SET @Index = 1
SET @WordCount = 0

WHILE @Index <= LEN(@InStr)
BEGIN
SET @Char = SUBSTRING(@InStr, @Index, 1)
SET @PrevChar = CASE WHEN @Index = 1 THEN ' '
ELSE SUBSTRING(@InStr, @Index - 1, 1)
END

IF @PrevChar = ' ' AND @Char != ' '
SET @WordCount = @WordCount + 1

SET @Index = @Index + 1
END

RETURN @WordCount
END
GO



now you can use that WordCount Function

DECLARE @String VARCHAR(4000)
SET @String = 'Hi this is Test line which count no of spaces.'
SELECT [dbo].[WordCount] ( @String )


Above Query will return Result 10 not any other,
hope you like this ,

Tuesday, September 8, 2009

SQL : how to sort ip Address.

ip address, is one of the key point to identify the user. now if your storing ip address on your database with the VARCHAR datatype with length of 25. guess you have 1 lakh's of records of different ip address and you want to sort that.

Then your sorting query will be

select [ipadd] as IpAddress from ip order by [ipadd]


now in this case it will return a result something like this


ipAddress
------------------------
10.0.0.1
192.165.20.2
255.205.2.3
255.145.53.6
64.35.88.9
68.4.5.99
69.65.236.235
98.125.85.36.0


something like that but actually its not your answer , it get sorted on first no. so becasue of that your result get warry.on actual basic the result should come in this format


ipAddress
------------------------
10.0.0.1
64.35.88.9
68.4.5.99
69.65.236.235
98.125.85.36.0
192.165.20.2
255.205.2.3
255.145.53.6


now how to achieve this use some technique here

select [IPAdd] from ip
order by CAST(PARSENAME([IPAdd], 4) AS INT),
CAST(PARSENAME([IPAdd], 3) AS INT),
CAST(PARSENAME([IPAdd], 2) AS INT),
CAST(PARSENAME([IPAdd], 1) AS INT),


now check this you get above result
thank you.

Monday, September 7, 2009

publish multiple websites using one solution.

on Visual Studio you can publish only one website at a time otherwise there is a clash between one website with multiple website.if you want to do that means on startup of one website other website also publish . for that you need to do some setting on Solutional Level.

follow the steps :
1- on proejct Solution just right click it & select Product Dependencies.
2- select Dependencies tab.
3- select your main website(startup one) from Dropdown.
4- now check all the web service on "Depends on" section
that you can decide how many site you want to publish at a time of this main site.
5- click ok

now whenever you publish that main site , then it will prompt publish window for all other depended site ,then all other mention site will also get publish , if you dont want to publish that you do the same above procedure to deactivated that ,

that's all...

Thursday, September 3, 2009

About XmlPreloadedResolver

when using Silverlight then XmlPreloadedResolver meaning is very useful, its a new type which can be useful when your working with XML . on XmlPreloadedResolver it has the Ability to load the DTD without call to network. This type manually maintain the DTD cache and all other with xml streams. XmlPreloadedResolver includes RSS1.0 and XHTML1.0 Defination of DTD.

sample code on how to work with XmlPreloadedResolver


String strDtd = "";
XmlPreloadedResolver resolver = new XmlPreloadedResolver();
resolver.Add(resolver.ResolveUri(null, "nameofDTD.dtd"), strDtd);
XmlReaderSettings rs = new XmlReaderSettings();
rs.XmlResolver = resolver;
rs.DtdProcessing = DtdProcessing.Parse;
XmlReader reader = XmlReader.Create("samplexml.xml", rs);



now you can also set the DTD sets Enable using XmlKnownDtds enumeration.
XmlKnownDtds is used with the XmlPreloadedResolver to identify the well-known DTD

the following example shos preloading Xhtml1.0 DTd into the XmlReaderSettings object
here there is no need of network call to parse the Xhtml file.it will done automatically.


XmlReaderSettings settings = new XmlReaderSettings();
//define the Setting object to parsing DTD
settings.DtdProcessing = DtdProcessing.Parse;
// Define preloading Xhtml10 DTD
settings.XmlResolver = new XmlPreloadedResolver(XmlKnownDtds.Xhtml10);
//suppose read the sample.html file using XmlReader
XmlReader reader = XmlReader.Create("sample.html", settings);
// and load using XDocument object
XDocument document = XDocument.Load(reader);


for more refer to : http://msdn.microsoft.com/en-us/library/cc189059(VS.95).aspx

Wednesday, September 2, 2009

Highlight Gridview's Row on mouseHover

in Gridview we have seen most of the time we one we take move hover to any row , size of that row or background color or any animation get happen you can do that using css, or java script also.

here i have do that using java script

function gvHigh(tRow,showAct)
{
if (showAct)
{
tRow.style.backgroundColor = '#ff32ss';
}
else
{
tRow.style.backgroundColor = '#ffffff';
}
}

function urlloca(Url)
{
document.location.href = Url;
}



and Define onrowCreated function like this and put your code behind here


protected void gv1_onRowCreated(object sender, EventArgs e)
{
foreach (GridViewRow gvRow in gv1.Rows)
{
gvRow.Attributes["onmouseover"] = "highlight(this, true);";
gvRow.Attributes["onmouseout"] = "highlight(this, false);";
HttpResponse myHttpResponse = Response;
HtmlTextWriter myHtmlTextWriter = new HtmlTextWriter(myHttpResponse.Output);
gvRow.Attributes.AddAttributes(myHtmlTextWriter);
}

}



that's it it will help you.
thank you.