Showing posts with label Tips and Tricks. Show all posts
Showing posts with label Tips and Tricks. Show all posts

Tuesday, November 12, 2013

Microsoft.Office.Interop.Word how to prevent word file opening

In my previous post i explained, how to Convert the dataset to xml string using  C# and asp.net
Now in this article i will explain how to prevent the word file opening, i have bunch of word document and i want to read/search text value out of it.  i tried that using Microsoft.office.Interop.Word object. 

Here is the sample code which prevent the word to opening the main window.
private void PreventOpenWord(string Filepath)
{
 Application word = new Application();
 FileInfo fileInfo = (FileInfo)file;


object save = false;
object confirmConversion = false;
object visible = false;
object skipEncodingDialog = true;
object readOnly = true;
object filename = fileInfo.FullName;

word.Visible = false;

Document srcDoc = word.Documents.Open(ref Filepath, ref confirmConversion, ref readOnly, ref missing,
    ref missing, ref missing, ref missing, ref missing,
    ref missing, ref missing, ref missing, ref visible,
    ref missing, ref missing, ref skipEncodingDialog, ref missing);




foreach (Microsoft.Office.Interop.Word.Range docRange in doc.Words)
{
if (docRange.Text.Trim().Equals(textToFind,
StringComparison.CurrentCultureIgnoreCase))
{
  
IsWordFound = true;
break;
}
}
}
catch (Exception ex)
{
 Response.Write("Error while reading file : " + ex.Message);
}
}


Hope this will helps you.. Happy  coding.. 

Saturday, October 19, 2013

Access content of iframe using jquery



It's very simple and straightforward.

Lets say, your using iframe and hello.aspx page like




1. < iframe id="frametemp" height="20px" width="90px"> </iframe>

which contain some control likes



2. <div id="divDisplayBox" > Say, Hello world! </div>

you can use .contents() method to find the specific id and like

3. $('#frametemp').contents().find('#divDisplayBox').html();

Hope this will helps you, Put your comments/suggestion if any.



 

Friday, September 6, 2013

Andriod KitKat

Yes, once again andriod version has been named base on dessert.

after the cupcake, donut, Gingerbread, ice-cream sandwish and jelly beans. new decided name of next version of andriod as favourite chocolate "Kit Kat".

Android 4.4 KitKat

As andriod says people can easily remember such name because they can't leave without chocoates. :)

Here are the some versions of Android in Pictures













    Looks good, isn't it?   Post your comments and queries to know more about KitKat

Monday, March 28, 2011

Export Gridview to PDF

we have seen how to export the data from gridview to Excel file, today this post will helps you to export the gridview data to PDF, if you want protect you data being edit/ cut/ delete then Export to PDF will be a better option for you.there is a open source project for iTextShart. you can download the dll from them and you can use it.

only you need to add this content on your page

Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment; filename= SampleExport.pdf");
Response.End();


Even you can format the text also,if you want to set the page with A4 or any other even you can also do the same.you can also specify the font size, style color all the basic things you can do with it.

you can download the code from the below link. you can try that it will helps you.

download Source

Sunday, July 18, 2010

how to add related posts on Blogger

we have seen on most of the blogger site , "Related post" section is there after every post now you want to add this Related post / Similar post on your blog ? follow the below easy steps and configure you blogger accordingly.

  • Open blogger.com site

  • Go to Design section under that you will get Edit Html Tab just click on it.

  • now before making any changes on your xml file just take abackup for safty

  • just click on "Expand widget templates "

  • Add the below code above the </head > section or better way is search the keyword </head>

    <script src='https://www.opendrive.com/files/6673148_cnSMd/RelatedPosts_Blogger.js' type='text/javascript'/>


  • now search for code <data:post.body/>

  • After this paste the below code line



  • <b:if cond='data:blog.pageType == "item"'>
    <div id='related-posts'>
    <font face='Arial' size='3'><b>Related Posts: </b></font><font color='#000000'><b:loop values='data:post.labels' var='label'><data:label.name/><b:if cond='data:label.isLast != "true"'>,</b:if><b:if cond='data:blog.pageType == "item"'>
    <script expr:src='"/feeds/posts/default/-/" + data:label.name + "?alt=json-in-script&callback=related_results_labels&max-results=5"' type='text/javascript'/></b:if></b:loop> </font>
    <script type='text/javascript'> removeRelatedDuplicates(); printRelatedLabels();
    </script></div></b:if>



  • now on the above code you will see the red section line "max-results=xx" here you can enter no of post you want to see on your page
    accordingly you can mention it.

  • now save you template and see the magic on your post

  • you will see the number of post after each article , before that you need to add label on your post. hope you like it


  • if you face any problem while doing this plz leave a comment.

Friday, June 11, 2010

How strong name assemblies keep you out of DLL Hell

while using Microsoft .NET framework for creating any application we are previously facing same problem with the DLL Hell. it arises a problem while updating a components so it breaks the other application which are depend on it. to overcome such a issues developer needs to implement the concept of Strong name .In this article you can through with how and why to use strong name .

Strong Name :
what is strong name? A Strong name is of information used to identify the assembly which may consist of Text-name , four part of version number , culture information , public key and the digital signature which may stored in a assembly manifest that get embedded on the file of the assembly.

By using the Strong name the CLR can assured that two assembly can be there with the same name. by the way strong name is basically provided the unique identification of the assembly. there are two scenarios in which the strong name can included in the assembly
1.Shared Assemblies
2. Serviced Components.

on the first case the shared assemblies can be used in the multiple application which may running on the same machine on GAC. and you may get the benefit ares:
1. Single Development
2. Bypass verification
3. Centralized update

yes as your getting such a good benefits then surely there is also a some issues on it that is
1.calling a private assemblies : if the shared assemblies can load with the type of private assembly then CRL will throw an Error because it reference only shared assemblies.
2. Trusting assemblies :
3. Installation issues :

How to create "Strong Name".
To create strong name for assembly you need a (al.exe) tool which is a assembly generation tool .now to create a key pair in the file you can use Strong name utility (Sn.exe) like this way.
Sn.exe -k filename.dat

The key file could be used on Al.exe to generate the strong name.
Al.exe /out:Input.dll /Keyfile:output.dat

Like this way you can design your strong name with the key. hope you get something from this
if you have any query on it plz post the reply.

Sunday, April 25, 2010

my oracle interview experience

hi friends,

last week i was attended "ORACLE financial services" interview for the .NET Developer post. Here i am sharing my experience on interview hope so it will help you while going for an Oracle Interview. i was disqualify from 3rd Round (Final Technical Round).

Interview Process:
There was 4 Round 1 st Online Test ( 47 Question 1 hrs ) but be careful there is also a negative marking as well as there is also a cutoff (if u select more than 1 answer and answer is wrong ) then again some deduction on your marks . Quite tough mostly Question on Assembly , Framework , C# , then hardly question on Datalist,Datagrid, Gridview and all basic. we totally 3 people get selected in first round out of 10.

Second Round is Technical Round. it was ok only basic question get ask during the interview , but in most of them are in-depth question just like on DataGrid DataBind() wht happen exactly , which function get executed at first onRowDataBound() or DataBind(). how .net life cycle will work on this process and all . i also got selected on this round .

now There was a Final Round on again Technical . There was 2 panelist in front of me and asking question on most of the SDLC (Software Development Life Cycle) and Question on backed on Pl-sql / SQL2005 . i thing around 15+ question get ask during the interview process i have answer most of them . but interview was cool .

at last there was an only final Round Remaining which is HR Round. but sorry to say friends i was disqualified from this process (2nd Technical Round). hope my this experience will help you to get it in ORACLE or any other software farm .because most of the time same process is there every where .

hope i will get good company out of this. better luck next time .but one thing is sure i am getting very good experience from this.

Wednesday, March 17, 2010

Tips on Google Buzz

on my previous post i was discuss on what is Google buzz , how you can add Google Buzz button on your Blogger / Wordpress. now on this article i am just discussing tips on Google Buzz , hope u enjoy this

1.Quick open Google Buzz
yes there are some keyboards shortkuts on gmail for opening google Buzz quickly, type g b from gmail view and Google Buzz will get open.
here are few more shortcuts.
m - mute
r- add comments
p/n - Go to new conversation
o -expand conversation
and so on.

2. Hide buzz Counter.
Now some time we dont want to view that google buzz counter on mail panal , now in this time you can remove that or hide that. Google has not given any facility to do so , but here is tricks to do this,
simple drag your lable (Buzz(3)) and and put this into More section . look at this image you will come to know

3. Subscribe Buzz feed

yes google posts each scrap to there user profile page. and you can open that by using orange icon display in your browser to subscribe a feed. it will looks this way
http://buzz.googleapis.com/feeds//public/posted


4.Add rich text

again this is a cool tricks on adding a rich text on your buzz message.
*bold message*
_italic message_
-deleted message-

5.View Photos in SlideShow Effects.

when ever you upload the images to the Google buzz , they basically added on Picasa albums, and when ever you clikc on that image it get open from there with the Light box effects , google has give that option that you can organize that photos according to your view and select the Slideshow option on it , then it get export those pics on picasa.

6.View Public Buzz message:

yes now you can search the public messages also with the help of google buzz. even though you can also restrict the
social connection on the buzz, that means you can protect your buzz while viewing to anyone else.
now how you can search it
author:@gmail.com : that means it will return all the buzz result with this email id. like this way
you can search it.
commenter:@gmail.com : this will search all the user that have given a comments .
has:photo, has:video, has:link : now here you can restrict the search just like if you enter has:photo that means only those result get sort out , those are hainvg photo in this buzz just like the videos and link and other

7 .Save searches

now not last but main useful feature is saving the search. what ever you have been search till time that get save automatically so later on also you can search it whtever search result your getting on previous search.

hope it will help you to make your buzz perfect , enjoy it happy buzzingg..

Monday, March 8, 2010

Add Google Buzz Button on Blogger

now you can use google Buzz buttons to share your ideas , pics, videos, and many more just like the twitter does,here is my post on how to add twitter button on your site or blog.the same you can add it for your google buzz basically if u search on google you get the lots of search on how to add google buzz button on Word-press blog, its very easy to do so you need to download the plugin and install it on your server that's it. but now u can use same on blogger too ,
Please follow the steps to add the Google buzz button

1.Sign in on your blogger account
2.Go to Dashboard section - Layout and click on Edit HTML
3.and it will show you HTML code , now try to search the keyword
<div class='post-header-line-1'>
on it,

4.now below that you can paste this code , google buzz provides you two button one is bigger one
just like this and smaller one too , here is code for large button

<a href='javascript:var%20b=document.body;var%20GR________bookmarklet_domain="http://www.google.com";if(b&&!document.xmlVersion){void(z=document.createElement("script"));void(z.src="http://www.google.com/reader/ui/link-bookmarklet.js");void(b.appendChild(z));}else{}'> <img alt='Buzz this' src='http://img2.pict.com/15/da/3e/2809374/0/googlebuzz.png'/> </a>

which will looks like


5.and here is compact button code
<a href='javascript:var%20b=document.body;var%20GR________bookmarklet_domain="http://www.google.com";if(b&&!document.xmlVersion){void(z=document.createElement("script"));void(z.src="http://www.google.com/reader/ui/link-bookmarklet.js");void(b.appendChild(z));}else{}'> <img alt='Buzz this' src='http://img2.pict.com/9c/09/57/2854010/0/buzzthis.gif'/> </a>
which will looks like



6.now save the template and see how exactly it appering on blog.

hope this article is helpful for you , thank you. if you have any problem while adding plz leave a comment we will help you.

Friday, December 18, 2009

SQL Database compare software

Here is free databse compare software for Access / MY SQL / Sql Serve , Compare application will allow you to compare the structure of two SQL server databases and display all the differences between them.. The structure viewer is included on same , you can find the comparison and acoording to that you can choose to exclude that comparioson of given fields , constraints .This is a lightweight version compared to version 2.0, it very small and portable.





>Download Here

Wednesday, December 9, 2009

Find Maximum Connections for SQL Server.

- If you want to know how many connection get happen with your database then you can easily get those number using this technique.

Select @@MAX_Connections as MaxConn

Using this you will get the Max number of connection get allowed on an instance of sql server.

- now if you want to know how many attempted connection are then

Select @@Connections as TotalNumberOfLogin

It will gives you all the number of connection was happen when the sql server get started , that may be a successful or unsuccessful connections also.

- You can also check this all using this system store procedure call

Exec sp_monitor

This will gives you result on when server get running , cpu time , usage , amount of data sending receiving , total number of read write operation done plus is there any error on connection like that .

Wednesday, November 25, 2009

How to know SQL Server version and Edition

some time we just install the sql server , but still we don't know which type of version it is and edition also , basically we need that when we are upgrating current version of new version. Current there is sql server 2008 is there in market,

now how to determine which version of sql 2008 is running out machine,
- run the following T-SQL statement,

SELECT SERVERPROPERTY ('productlevel') ,SERVERPROPERTY('productversion'), SERVERPROPERTY ('edition')

you will get the result like :
RTM | 10.0.1600.22 | Enterprise Edition

RTM is product level which means - 'Release To Manufacturing'.
but what is means of RTM - is a stage on which the distribution of process begins CD of
that product get created and retial packs and then product will get shipp , this is very
long process and because of that RTM date is mostly ahead of the final release date.

10.0.1600.22 means product version.

Enterprise Edition means its a Edition there are some other editions are also there like
Developer,standard ,web,Express ,Workgroup , 64- bit Edition .

The following table lists the Sqlservr.exe version number.








Release Sqlservr.exe
RTM 2007.100.1600.0
SQL Server 2008 Service Pack 12007.100.2531.0

Wednesday, November 18, 2009

Check for valid Internet Connection using C#

on many application we need internet connectio , such as smart client to send receive the data, now in this case below code will help you to make sure that you have proper internet connection or not , the conecpt is like very simple, at first we simply check that if the user has network connection and according to that it will return Success / Fail message.

Now i just ping the two website (www.google.com ,www.yahoo.com) which will ping that site and return fail or success message.


C#
public bool GetIsConnAvail()
{
var success = false;
string StatusMsg;
if (NetworkInterface.GetIsNetworkAvailable() == false)
{
return success;
}
string[] Mysite = { "www.google.com", "www.yahoo.com"};
try
{
using (var ping = new Ping())
{
foreach (var url in Mysite)
{
var replyMsg = ping.Send(url, 300);
if (replyMsg.Status == IPStatus.Success)
{
success = true;
StatusMsg = "Connection Found..."
break;
}
else
{
StatusMsg = "Internet Connection not Found on your machine..."
}

}
}
}

catch (Exception ex)
{
Trace.WriteLine(ex.Message);
}
return success;
}



i thing this code will surely help you to search your connection faster than other ways.

Tuesday, November 10, 2009

video on web2.0

hi , i just found very nice vodeo on web2.0





another video on web2.0 , its really very informative

Wednesday, November 4, 2009

Generate Sitemap using ASP

Sitemap is very important factor of web site , you can say its a list of pages of web site accessible to user. it Organize in hierarchical fashion. basically it helps the visitors and mostly on search engine bots to find the perticular page on you site. it improve seo of site , it works just like the dynamic access to site. basically sitemap in xml format.



Here i have created one sample application that can read xsl file and according to that it generate sitemap of your site.
on my Excel file i have place all the links of my sites.
now how to get this ,
1 .open your site say www.google.com
2. now on your web developer toolbar (Mozilla addon) on Information section > click view link information it will open open page and in that you can find all the site links
3. copy that on excel file and save it ,

now write application that read a data from excel and generate sitemap



< %

Const adOpenStatic = 3
Const adLockPessimistic = 2
Dim cnnExcel
Dim rstExcel
Dim I
Dim iCols

Set cnnExcel = Server.CreateObject("ADODB.Connection")
cnnExcel.Open "Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq="&Server.MapPath("1.xls")&";DefaultDir="&Server.MapPath(".")&";" Set rstExcel = Server.CreateObject("ADODB.Recordset")
rstExcel.Open "SELECT * FROM [Sheet1$]", cnnExcel
iCols = rstExcel.Fields.Count
rstExcel.MoveFirst
xmlData = ""
xmlData = xmlData&""
Do While Not rstExcel.EOF
xmlData = xmlData& ""
xmlData = xmlData& ""& rstExcel.Fields.Item(0).Value & "" & vbCrLf
xmlData = xmlData& "
"
rstExcel.MoveNext
Loop
xmlData = xmlData& "
"
Response.Write(xmlData)
rstExcel.Close
Set rstExcel = Nothing

cnnExcel.Close
Set cnnExcel = Nothing
% >

Run this file and view source code of this file , save view source file as a "Sitemap.xml"

Friday, October 16, 2009

File comparison tool free download.

sometime we need to compare two file ,like comparing coding or some text like that , in that time if the document is too long then Comparing this will be very difficult .

here i found very nice file comparison tool call Turtoise SVN .
Turtoise SVN is Free and it can provide file comparison facility same as popular beyond compare tool.

steps
1. Download the SVN

2.select the two file you want to make the comparison. here i have created two files test1 &test2


3. now select two file right click on mouse , and select "Diff" option on same ,

4. It will show you the difference between two files.


that's it falk,

Saturday, October 3, 2009

Google Maps Api

There are lot many service provided by Google ,

Google map

is one of that , which can be used to discover the world through your application , you can used this for many other purpose just like bookmarking you city,state, your Company and many more.

here is Google api you can integrate with you .net application, below is code how you can do that but The first thing if you wanted a google map Api key for Local server testing you may download here.

"ABQIAAAA5HHs8lZl18SY-r1Jm1qy-hQpDmmpk8q921mRIPG4qgOvy0T09hTGvwPs_FnHiEq78dTl61JP9JQQtw" this is test key for yout local server and IIS



Google.zip (701.00 bytes)

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

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.

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 ,