Nilesh Rathod

Script to Remove or Check Special Charater from Javascript

Posted by Nilesh Rathod on January 24, 2012

To Remove or Check Special Charater from Javascript

Call  Javascript function on “onkeyup” event of TextBox

<asp:TextBox ID=”TextBox1″ runat=”server” onkeyup=”valid(this)” Width=”610px”></asp:TextBox>

Javascript :

<script type=”text/javascript”>

function valid(field) {
var txt = document.getElementById(‘TextBox1′).value;
var iChars = “!@$%^&*()+=-[]\\\’;,./{}|\”:<>?~_”;
for (var i = 0; i < txt.length; i++) {
if (iChars.indexOf(txt.charAt(i)) != -1) {
alert(“Your string has special characters. \nThese are not allowed.”);
document.getElementById(‘TextBox1′).value = txt.substring(0, txt.length – 1);
return false;
}
}

}
</script>

Above script check all given Special character which is in iChars and substring function will remove that entered character

Posted in Asp.Net, Javascript | Leave a Comment »

Asp.net string Check null or empty string

Posted by Nilesh Rathod on January 24, 2012

To Check null or empty string  one trick is given below

string str = “Demo”;
str = “”;

if (Convert.ToString((object)str) != string.Empty)
{
Response.Write(“Null String”);
}

Posted in Asp.Net | Leave a Comment »

Sharepoint 2010 How to read File from Library

Posted by Nilesh Rathod on January 11, 2012

To read File from Library and replace that value in Sharepoint library use below code.

protected void btnReadFile_Click(object sender, EventArgs e)
{
string strSubject = “New Subject Line”;
string strMessage = “New Message Line”;

string content = string.Empty;
using (SPSite oSite = new SPSite(SPContext.Current.Site.Url))
{
using (SPWeb oWeb = oSite.OpenWeb())
{
SPDocumentLibrary doclib = (SPDocumentLibrary)oWeb.GetList(“Documents”);
SPFile htmlFile = doclib.Items[0].File;
using (System.IO.StreamReader reader = new System.IO.StreamReader(htmlFile.OpenBinaryStream()))
{
content = reader.ReadToEnd();
}
}
}

content = content.Replace(“@xSubjectx@”, strSubject);
content = content.Replace(“@xMessagex@”, strMessage);
lblOutput.Text = content;

}

Posted in Asp.Net | Leave a Comment »

How to pass URL in Link and open Outlook

Posted by Nilesh Rathod on January 2, 2012

To Open outlook from Link and also send Url use following code

<script language=”javascript” type=”text/javascript”>
var varname = “https://www.google.com/”;
</script>

Now get that variable value in Link as

<a href=”mailto:me@domain.com?subject=You can specify subject too&body=”onclick=”location.href=this.href+”+varname;return false;”>Send Email</a>

Posted in Javascript | Leave a Comment »

Sharepoint 2010 How to make Webpart Chrome Property None

Posted by Nilesh Rathod on December 23, 2011

To make Chrome Type Property None
public override PartChromeType ChromeType
{
get { return PartChromeType.None; }
set { base.ChromeType = PartChromeType.None; }
}

Posted in Sharepoint Developement | Leave a Comment »

How to Check Image is Exist or not on Server

Posted by Nilesh Rathod on December 23, 2011

To check from Image path that it is exist or not on server -

 
if (UrlExists(ImageURL))
{
Image1.ImageUrl = ImageURL;
}
else
{
Image1.ImageUrl = NoImageURL;
}

private static bool UrlExists(string url)
{
try
{
new System.Net.WebClient().DownloadData(url);
return true;
}
catch (System.Net.WebException e)
{
//if (((System.Net.HttpWebResponse)e.Response).StatusCode == System.Net.HttpStatusCode.NotFound)
return false;
//else
throw;
}
}

Posted in Sharepoint Developement | Leave a Comment »

SP2010 Useful Links

Posted by Nilesh Rathod on November 14, 2011

Sharepoint InfoPath Leave Application Form

http://www.screencast.com/t/MmJjZDk3ODk

Sharepoint Video

http://www.screencast.com/users/jthake/folders/SharePointDevWiki.com%20Screencast/media/dda081c8-18c2-43f5-adfd-8f95c59f2113

All About Infopath

http://www.squidoo.com/infopath-sharepoint-2010

http://wn.com/Building_Forms_with_InfoPath_2010

http://gurubootcamp.net/microsoft/infopath-2010-introduction-part-1-create-a-simple-form

Fetch User From Sharepoint Server

http://www.edutechnow.com/?p=446

Coding In Infopath

http://johanolivier.blogspot.com/2010/08/infopath-2010-development-part-1-add.html

Infopath Ger Current User

http://blogs.microsoft.co.il/blogs/itaysk/archive/2007/04/05/InfoPath-_2D00_-Get-the-current-user-without-writing-code.aspx

http://blogs.msdn.com/b/jingmeili/archive/2007/05/31/how-to-display-current-user-s-full-name-email-and-other-info-in-infopath.aspx

Superb All Video

http://wn.com/Building_Forms_with_InfoPath_2010

SP Designer and Work Flow

http://www.dotnetcurry.com/ShowArticle.aspx?ID=695

WorkFlow

http://www.codeproject.com/KB/sharepoint/StateMachineWorkflows2.aspx

All Infopath Feature

http://www.sharepointhoster.com/40-awesome-features-of-infopath-2010.html

Infopath Insert Data into SQL

http://blogs.msdn.com/b/jannemattila/archive/2007/01/21/infopath-and-web-service-data-connection.aspx

http://blogs.msdn.com/b/jannemattila/archive/2007/10/25/from-infopath-to-database-via-web-service.aspx

Sharepoint Link for Customization

Remove Left Navigation

http://virtualizesharepoint.com/2011/03/31/removing-the-left-hand-navigation-in-sharepoint-2010/

Remove Left Navigation

http://sharepoint.jonthomson.co.uk/workshop/SitePages/Home.aspx

Hide Quick Launch

http://chrisstahl.wordpress.com/2010/03/15/hide-the-quick-launch-in-sharepoint-2010/

Add Flash File

http://virtualizesharepoint.com/2011/04/05/adding-flash-to-sharepoint-2010/

InfoPath Advance Form Option for Save and Save As Option

http://virtualizesharepoint.com/2011/05/15/infopath-2010-advanced-form-options/

Ribbon Customization

http://styledpoint.com/blog/ribbon-customization-changing-placement-look-and-behavior/

Active Directory change to add new Field

http://virtualizesharepoint.com/category/active-directory/

 List Exceeds Browser Window

http://www.estruyf.be/blog/problem-with-list-views-that-exceeds-browser-window-width/

Cascading Drop Down List

http://msdnvietnam.net/blogs/quang/archive/2010/03/30/cascading-drop-down-list-in-sharepoint-2010-using-infopath-2010.aspx

Start Organization browser at Any Account

http://www.tcscblog.com/2011/07/29/start-the-organization-browser-at-any-account-name/

Delete Orphaned User

http://nikspatel.wordpress.com/2010/08/10/delete-orphaned-ad-users-from-the-site-collection/

List of SharePoint Site Collection Users

http://blogs.officezealot.com/mauro/archive/2005/03/14/4329.aspx

Sharepoint and Sql Server

http://www.chandima.net/Blog/archive/2010/07/16/sharepoint-2010-and-sql-server-databases-%E2%80%93-what-are-they-why-are-they-there.aspx

Posted in Asp.Net, Sharepoint Developement | Leave a Comment »

Sql Server Remove Duplicate Value From a Table

Posted by Nilesh Rathod on September 26, 2011

How to Remove Duplicate Value From a Table

If We have a table like following and we need to remove Duplicate Value

ID FNAME LNAME
1 AAA CCC
2 BBB DDD
1 AAA CCC
2 BBB DDD
1 AAA CCC
2 BBB DDD
3 BCB DGD

If we want to remove duplicate value from above table
Than we can use following Query

SELECT DISTINCT * INTO NEWTABLE FROM OLDTABLE
TRUNCATE TABLE OLDTABLE
INSERT INTO OLDTABLE SELECT * FROM NEWTABLE

Sql Server Remove Duplicate Value From a Table

Posted in Sql Server | Leave a Comment »

Sql Server Count Duplicate Records – Rows

Posted by Nilesh Rathod on September 26, 2011

Count Duplicate Records – Rows

If We have a table like following and we need to find No of Duplicate column than follow 

1	AAA	CCC
2	BBB	CCC
2	BBB	DDD
3	CCC	DDD
3	CCC	DDD
3	CCC	DDD
1	AAA	CCC
1	AAA	CCC
1	AAA	CCC
1	AAA	CCC
2	BBB	DDD
2	BBB	DDD

If You want to Count Duplicate Values in Column 

SELECT ID , COUNT (*) AS COUNTMULIPLE FROM SAMPLE
GROUP BY ID
HAVING COUNT(*) > 1

 

Posted in Sql Server | Leave a Comment »

Asp.Net Gridview Eval Condition

Posted by Nilesh Rathod on August 16, 2011

Below Eval is used  Conditional Operator

<asp:TemplateField HeaderText=”Gender”>

<ItemTemplate>

<asp:Label ID=”lblGender” Text=’<%# string.Compare((string)Eval(“Gender”), “M”,false)==0?”Male”:”Female”%>’ runat=”server”>                  </asp:Label>

</ItemTemplate>

</asp:TemplateField>


			

Posted in Asp.Net | Leave a Comment »

 
Follow

Get every new post delivered to your Inbox.