Posts

Showing posts from November, 2008

Play Video with asp.net and c#

.flv is the preferred format to play videos online. You can download .flv player from http://www.any-flv-player.com and then go to Publish>>Publish for web. This will generate code copy and paste code to .aspx page. It will start playing your .flv file You can face a major problem on server or IIS it will not play video. Go to settings and set MIME type to .flv

How to make user in Sql server database.

Image
To make a user in sql server you have the rights. to create user go to Security=>> Logins>> Right click on Logins Login Name : jayant Select option:Sql server authentication Un check : Enforece password policy. Refer Image Below Now close sql management studio and re login with jayant Try to access other databases, it will show error, means you have sucessfuly make a new use for new datbase.

Crosstab report in SQL server (Pivot)

Microsoft introduces new operators PIVOT and UNPIVOT in SQL Server 2005. Traditionally we create queries using the CASE statement and aggregate function in order to produce cross-tab reports. This article illustrates the usage of the new operators, PIVOT and UNPIVOT. Let us assume that we have a table as described below. Create table #MyTable (yearofJoining int, EmpId int, Deptid int) go insert into #MyTable select 1990,1,1 insert into #MyTable select 1991,2,2 insert into #MyTable select 1990,3,4 insert into #MyTable select 1991,4,2 insert into #MyTable select 1990,5,1 insert into #MyTable select 1990,6,3 insert into #MyTable select 1992,7,3 insert into #MyTable select 1990,8,4 insert into #MyTable select 1993,9,1 insert into #MyTable select 1994,10,2 insert into #MyTable select 1990,11,3 insert into #MyTable select 1995,12,3 insert into #MyTable select 1995,14,3 insert into #MyTable select 1995,15,3 insert into #MyTable select 1995,16,6 go In order to create a cross tab report, we ...

Event after Load

Yes there is an event LoadComplete() for ex. protected void Page_LoadComplete(object sender, EventArgs e) This event is for tasks that require that all other controls on the page be loaded. Suppose I have to show messages on page and then I have to redirect to some other page. I Have a small example; I have a page which connect me to some more URL’s but to some reasons I have shift that page to another location. Now I have to show message on page “this page has shifted to another location. This page will automatically redirect to another page” So, this can be done only after page load so, this is the best event to place that code

Randomly Sort Sql server Table

You can sort a Table Randomly with a single keyword. the newsid() is the keyword which generates a random number in sql server. Here is small ex. 1)Create a database 2)Create Table Master 3)Create Fields Code nvarchar(50), Name Nvarchar(50) 4)Enter some data into table 5)Now open new query window 6)Write sql 7) Select * from Master Order by newid() Now, run this code it will return data in random format. You can also use newid() to generate a unique number or a number like verification code etc. for ex. Select newid()

Sort Datatable randomly

This is not possible to Sort a Datatable directly. In order to randomize the rows in a DataTable, do the following: 1) Add a random number DataColumn to the DataTable 2) For each row, generate a random number and store it to the new column 3) Create a DataView and sort by the random number DataColumn Test this by simple ex. DataTable dt = GetData(); dt.Columns.Add(new DataColumn("RandomNum", Type.GetType("System.Int32"))); Random random = new Random(); for (int i = 0; i { dt.Rows[i]["RandNum"] = random.Next(1000); } DataView dv = new DataView(dt); dv.Sort = "RandomNum";

How to use Hindi fonts on Website

Now in current world the importance of multi lingual websites has increased. People demands for sites in different languages for different uses. I have a site on which I have to show data in Hindi. This had become a major issue while development. I had searched the internet and found a solution named Microsoft WEFT. I was very happy to find a solution. I start working on the basis of this software. But after successful launch of website the use had found an major issue. The .eot files are only supported on IE browsers. Now, this is the time to work like a machine to search for a true solution. I have searched many sites. But, finally god give me the solution by giving me the concept of UNICODE fonts Here is the example how to use UNICODE fonts. use these sites to make entry in hindi http://utopianvision.co.uk/hindi/write/ http://www.geocities.com/matthewblackwell/hindiEditor.html You can make entry in hindi for ex. on this http://utopianvision.co.uk/hindi/write/ in second text box ente...

aspnet_merge.exe exited with code '1'

This is a major problem which will normally faced by new users of .net. The main reason behind the problem is the duplicate "Inherits" name of pages. You can easily resolve this problem by renaming the duplicate inherit names of Pages. Let me describe this by giving an simple ex. steps :- 1) Make a new c# website. 2) By default an page default.aspx will appear. 3 Copy default.aspx and paste 4) Rename copy of default to "Default2.aspx" 5) Then try to make build. 6) It will show errors Here, is the solution 1) Open default.aspx 2) Check Inherits attribute of page in page directive. it is "_Default" by default 3) Open default2 4) Check Inherits attribute of default2 in page directive. it is "_Default" 5) Change Inherits attribute of default2 to "_Default2" 6) Build application Now build successfully. This is the solution which I have explained with the help of small ex. For any help please mail on narendersinghkahlon@gmail.com

How to change Mouse Pointer onmouseover using Javascript

JavaScript is a strong tool to work with Web Technology. You can complete all the tasks using JavaScript. For ex. I have a task to chnage mouse pointer on mouse hover. The answer is too simple use CSS.No, my css is not working due to some un avoidable reasons. Finally I come to the conclusion i.e Make a global.js contains function set_mouse_pointer(obj) { obj.style.cursor='pointer'; } Then implement this function like Steps: 1) Put an HTML button of the page 2) Then on onmouseover event write code "onmouseover="set_mouse_pointer(this);" 3) View that page in browser. You will see the effect. This is a simple example of JavaScript. What you can do with JavaScript. Please let me know if you have any major issues related to JavaScript

Set Left,Top at different screen resolution by JavaScript

I have a task to dispaly a div starts from the left position of some other control. I had searched on so many sites but, unfortunately I have not found any good solution. But, finally I found a solution, as I know the default left on 1024 x 768 is "251" so I use this as a gift of god. Following is the code how to do that:- var obj=document.getElementById("a1"); var int_left=screen.width; // get Pixel size of screen if (int_left>1024) { int_left=int_left-1024; // get width other then 1024 int_left=int_left/2; get the first half of width int_left=int_left+251; add first half to the width } else { int_left=253; } obj.style.left=int_left; If you have any doubts please let me know.

Browser compatible Javascript.

If you want to navigate form one window to another use window.location='pagename.htm' This is a browser compaitable script. I will continue to post more browser compaitable scripts as I will come to know more issue or get request from someone

SQL Server Stored Procedure paging with .net

We face Paging problem while working with datalist. Datalist does not support paging like grid. Here, is the solution for this major problem. use Sql server stored procedure to get proper paging which we can call from Dot Net Suppose I have a Table master Contains Fields "UserName,Code, Address1,FatherName" etc. To Make this ex. working follow steps 1) Make New Database 2) Create Table Master 3) Create Fields UserName Nvarchar(50), Code Nvarchar(50), Address1 Nvarchar(50), FatherName Nvarchar(50) 4) Then run following command is sql query window. 5) After creating this exec [Get_Records] 1,10 6) First param stands for pageno and second is for No. of records per page. -- ============================================= Create PROCEDURE [dbo].[Get_Records] @Int_PageNo int,@Int_RecordPerPage int AS BEGIN Declare @Int_From_Page int,@int_To_Page int,@Int_Total_Records int /***********************************************/ set @Int_From_Page=((@Int_PageNo-1)*@Int_RecordPerPage)+1...

Absolute path to Javascript

Many time we face a problem of JavaScript path Like you have given path in Master page like "../a.js" so, if you have page at "../../../default.aspx" position it will not import this Js into your page or you will face problem with JS. So if you want to use a perfect path for your JS use Resolve URL method. For ex. <script type="text/javascript" src="<%=ResolveUrl("~/js/example.js")%>"></script> This is the right way work with Dot Net and JS