How to use Asp.net
  • Home
  • About us
  • Disclaimer
  • joy of helping
KEEP IN TOUCH

Monthly archives for January, 2012

How to Upload and crop images with jquery in ASP.NET C#

Jan25
2012
15 Comments Written by vikram

After reading alot on the net in this article will let you know with the help of jqueries that how can we upload the image and crop it according to our choice like we do in orkut or in facebook. i just tried to do something similar. Well,  first of all create folders name “images” which will keep the image for cropping and under images create “crop” name folder which will keep the proportionate cropped image files and last one create “Profile_pics” which will crop the proportionate cropped image once again and this one is optional you can remove that methods. In this article i have restricted the image size which is “200kb” only so you can  increase it. Hope you will like this article.

*create a page “Default2.aspx”

Now, Copy paste the source code below.

<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”Default2.aspx.cs” Inherits=”Default2″ %>

 

<!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=”Head1″ runat=”server”>
<title>crop images asp.net</title>
<link href=”jquery.Jcrop.css” rel=”stylesheet” type=”text/css” /><script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js”></script>
<script src=”js/jquery.Jcrop.min.js” type=”text/javascript”></script>
<script type=”text/javascript”>

jQuery(function($){

// To hold the API and image size.

var jcrop_api, boundx, boundy;
$(‘#img_crop’).Jcrop({  // img_crop is the ID of image control
onChange: updatePreview, // will display the selected img on change.
onSelect: updatePreview, // will display the selected img Img_preview
onSelect: storeCoords, // will tell the coordinates
aspectRatio: 1
},function(){
var bounds = this.getBounds();
boundx = bounds[0];
boundy = bounds[1];
jcrop_api = this;
});

function updatePreview(c)
{
if (parseInt(c.w) > 0)
{  var rx = 100 / c.w;
var ry = 100 / c.h;
$(‘#Img_preview’).css({  //Img_preview is the ID of image control
width: Math.round(rx * boundx) + ‘px’,
height: Math.round(ry * boundy) + ‘px’,
marginLeft: ‘-’ + Math.round(rx * c.x) + ‘px’,
marginTop: ‘-’ + Math.round(ry * c.y) + ‘px’     });
}   }; });

READ MORE »

Posted in Asp.net

Returning complete words with a Left and Charindex in sql server

Jan23
2012
2 Comments Written by vikram

Here i m explaining that how can we display the full string without any half word e.g. 1st line output with header name string will let you know about the substring in which the last word ‘industry’ is not proper displaying as such i have used a substring function with 100 characters. so thats why its not displaying the full word. To overcome this problem i have tried  something after search on the web and posting it on my website  which might helpful for u .

* this query can help us where we have to display news with read more …

– below variable @Str decalaration

Declare @Str varchar(200)

– assigning the String in @Str

set @Str =’Lorem Ipsum is simply dummy text of the printing & typesetting industry. Lorem Ipsum has been the industry standard dummy text ever since the 1500s, when an unknown printer took a galley of type.’

– substring 100 characters from @Str
select substring(@Str,0,100) as string

 

– with left and charindex keyword displaying the full words.
select Left(Left(@Str, 100), LEN(Left(@Str, 100)) – CHARINDEX(‘ ‘, REVERSE(Left(@Str, 100)))) AS msg

OUPTUT

*click on the below image and see the red mark at the string header named output

with regards
vik

Posted in Sql Server

Getting the isoweek number sql server 2005

Jan21
2012
Leave a Comment Written by vikram

Hello there, Actually i was facing problem last year to get the exact week no. of the year.  i found the following code which will let us know the exact week no. of the year. so, i thought to put an article on my site. It will help to other also.  just copy and paste the following script into your database to get the isoweek / week number.

 

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE FUNCTION [dbo].[ISOweek]  (@DATE DATETIME)

RETURNS INT

AS

BEGIN

DECLARE @ISOweek INT

SET @ISOweek= DATEPART(wk,@DATE)+1

-DATEPART(wk,CAST(DATEPART(yy,@DATE) AS CHAR(4))+’0104′)

–Special cases: Jan 1-3 may belong to the previous year

IF (@ISOweek=0)

SET @ISOweek=dbo.ISOweek(CAST(DATEPART(yy,@DATE)-1

AS CHAR(4))+’12′+ CAST(24+DATEPART(DAY,@DATE) AS CHAR(2)))+1

–Special case: Dec 29-31 may belong to the next year

IF ((DATEPART(mm,@DATE)=12) AND

((DATEPART(dd,@DATE)-DATEPART(dw,@DATE))>= 28))

SET @ISOweek=1

RETURN(@ISOweek)

END

GO

 

——————————————————————————————————–

How to execute see the following example..

select getdate() as currentdate
select DBO.ISOWEEK(getdate()) as weekno

 

 

with Regards
vik

Posted in Sql Server

How to check all CheckBox in GridView in asp.net C#

Jan19
2012
Leave a Comment Written by vikram

Hello there, this time I will do something like we do in our email inbox items where we can delete our emails one by one or all at once after selecting the Checkbox. I have tried with database for simple example and you can do it according to your requirements. Hope you will like this post.

DATABASE SCRIPT

  • Create a database and name to db_gridview_chkbox and copy paste the following script into your sql sever.

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[tbl_messages](
[id] [bigint] IDENTITY(1,1) NOT NULL,
[to_subject] [varchar](500) NULL,
[from] [varchar](12) NULL,
[date] [datetime] NULL CONSTRAINT [DF_tbl_messages_date]  DEFAULT (getdate())
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO

SOURCE CODE

  • Now add a new page and name it Default.aspx and copy paste the following source code in it.

READ MORE »

Posted in Asp.net

Joy of Helping

Any sort of help to the children who are fatherless, poor & are from far-off areas.
Joy of Helping

Facebook Link

Asp dot Net ,Ajax,Xml.

Recent Posts

  • ROW_NUMBER(), NTILE(), partition by, Duplicate Records, CTE sql server 2008
  • How to get second highest Salary sql server 2008
  • Insert values, insert into, insert default value, insert execute and select into sql server 2008
  • How to Bind GridView with SqlDataReader in Asp.net
  • how to attach files to email without storing on disk using Asp.net FileUpload control

Recent Comments

  • Anonymous on ROW_NUMBER(), NTILE(), partition by, Duplicate Records, CTE sql server 2008
  • dhananjay on How to use GridView with Insert, Edit, Update, Delete the Ado.net way C#
  • dev on How can we limit the characters in multiline textbox asp.net using JavaScript
  • navneet on How to display image in Image control after upload on the server asp.net C#
  • AnhVu on How to do Shopping Cart in Asp.net C#

Archives

  • February 2013
  • September 2012
  • April 2012
  • January 2012
  • October 2011
  • August 2011
  • May 2011
  • April 2011
  • March 2011

Categories

  • Asp.net
  • jQuery
  • Sql Server

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org

EvoLve theme by Theme4Press  •  Powered by WordPress How to use Asp.net