RSS

Monthly Archives: July 2011

Getting the Identity of the last Inserted row


hi..

If you want to get the identity of the table at the time of insert ,so use this sp
create PROCEDURE [dbo].[EmployeeData_Insert]

@FirstName    varchar(100),
@LastName    varchar(100),
@Title    varchar(10),
@DateCreated    smalldatetime,
@DateModified    smalldatetime

AS

INSERT INTO [employeeData]
(
[FirstName],
[LastName],
[Title],
[dateCreated],
[dateModified]

)
VALUES
(
@FirstName,
@LastName,
@Title,
@DateCreated,
@DateModified

)

declare @_id_EmployeeID_ int
set @_id_EmployeeID_ = @@IDENTITY

SELECT
[employeeID]
FROM [employeeData]
WHERE
[employeeID] = @_id_EmployeeID_

Advertisements
 
Leave a comment

Posted by on July 22, 2011 in SQL Query

 

Tags: , , , ,

dropdown open at mouseover


in this article you can select or redirect link just mouse over on dropdown list ( selection dropdown)

 

<html xmlns=”http://www.w3.org/1999/xhtml”&gt;

<head runat=”server”>

<title></title>

<style type=”text/css”>

body

{

background-color:#D5C0D5;

}

#appcenter

{

margin: 0 0 0 40px;

padding: 0;

}

#sddm

{

margin: 0;

padding: 0;

z-index: 30;

}

#sddm li

{

float: left;

font: bold 12px arial;

list-style: none outside none;

margin: 0 0 6px;

padding: 0;

}

.selectaloan:link, .selectaloan:active, .selectaloan:visited

{

background: url(“images/ddl-selectaloan.jpg”) no-repeat scroll 0 0 transparent;

color: #000000;

display: block;

font-size: 11px;

font-weight: normal;

height: 17px;

list-style-type: none;

outline: medium none;

padding: 1px 0 0 4px;

text-decoration: none;

width: 167px;

}

#sddm div

{

border-bottom: 1px solid #ACADB2;

border-left: 1px solid #ACADB2;

border-right: 1px solid #ACADB2;

margin: 0;

padding: 0;

position: absolute;

visibility: hidden;

width: 165px;

}

#sddm div a

{      position: relative;

display: block;

margin: 0;

padding: 1px 4px;

width: auto;

white-space: nowrap;

text-align: left;

text-decoration: none;

color: #000;

background:#FFF;

font: 11px arial}

 

#sddm div a:hover

{      background: #3399FF;

color: #FFF}

</style>

<script type=”text/javascript”>

<!–

var timeout = 100;

var closetimer = 0;

var ddmenuitem = 0;

function mopen(id) {

mcancelclosetime();

if (ddmenuitem) ddmenuitem.style.visibility = ‘hidden’;

ddmenuitem = document.getElementById(id);

ddmenuitem.style.visibility = ‘visible’;

}

function mclose() {

if (ddmenuitem) ddmenuitem.style.visibility = ‘hidden’;

}

function mclosetime() {

closetimer = window.setTimeout(mclose, timeout);

}

function mcancelclosetime() {

if (closetimer) {

window.clearTimeout(closetimer);

closetimer = null;

}

}

//document.onclick = mclose;

// –>

</script>

</head>

<body>

<form id=”form1″ runat=”server”>

<div id=”appcenter”>

How do I access my Website?<ul  id=”sddm”>

<li><a onmouseover=”mopen(‘m1’)” onmouseout=”mclosetime()” href=”#”>

http://www.google.com</a><div style=”visibility: hidden; z-index: 9999;” id=”m1″ onmouseover=”mcancelclosetime()”

onmouseout=”mclosetime()”>

<a href=”#”>www.yahoo.com</a><a href=”#”>www.hotmail.com</a><a href=”#”>

http://www.wordpress.com</a><a href=”#”>www.geo.tu/urdu</a><a href=”#”>www.youtube.cocm</a><a

href=”#”>www.facebook.com</a></div>

</li>

</ul>

</div>

</form>

</body>

</html>

 

ddl-selectaloan.jpg Image

OutPut

 

 
Leave a comment

Posted by on July 22, 2011 in Java Script

 

Tags: , ,

How to open new window (popup) and center on screen


Hi …

the advantage  of this java script function you just place in master page and call any where at page ……..
<html>
<head>
<title>Popup Window</title>
<script language=”javascript” type=”text/javascript”>
<!–
var win=null;

function NewWindow(mypage,myname,w,h,scroll,pos){

if(pos==”random”)
{LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}

if(pos==”center”)
{LeftPosition=(screen.width)?(screen.width-w)/2:100;
TopPosition=(screen.height)?(screen.height-h)/2:100;}

else if((pos!=”center” && pos!=”random”) || pos==null){LeftPosition=0;TopPosition=20}

settings=’width=’+w+’,height=’+h+’,top=’+TopPosition+’,left=’+LeftPosition+’,scrollbars=’+scroll+’,l ocation=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes’;

win=window.open(mypage,myname,settings);}
// –>
</script>
</head>

<body>

<table width=”100%” height=”100%”>

<tr>
<td align=”center” valign=”middle”>
<a href=”https://humrahimcs.wordpress.com&#8221; onclick=”NewWindow(this.href,’newwindow’,’450′,’500′,’yes’,’center’);return false” onfocus=”this.blur()”>Popup Window</a>
</td>
</tr>
<tr>

</table>
</body>
</html>

 
Leave a comment

Posted by on July 22, 2011 in Java Script

 

Tags: , , , , , , , ,

Creating Collapsible Detail Regions in a Repeater


In this article we’ll examine how to display data in collapsible manner using a Repeater. By the end of this article you’ll have the complete code and concepts for creating such a slick user interface yourself, and helping prevent against data overload in your Web applications.

Client Side 

hideshowdiv.aspx

<<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head runat=”server”>
<title></title>
<style type=”text/css”>
.header
{
font-size: larger;
font-weight: bold;
cursor: hand;
cursor: pointer;
background-color: #cccccc;
font-family: Verdana;
}
.details
{
display: none;
visibility: hidden;
background-color: #eeeeee;
font-family: Verdana;
}
</style>
<script language=”JavaScript” type=”text/javascript”>
function ToggleDisplay(id) {
var elem = document.getElementById(‘d’ + id);
if (elem) {
if (elem.style.display != ‘block’) {
elem.style.display = ‘block’;
elem.style.visibility = ‘visible’;
}
else {
elem.style.display = ‘none’;
elem.style.visibility = ‘hidden’;
}
}
}
</script>

</head>
<body>
<form id=”form1″ runat=”server”>
<asp:Repeater ID=”rptFAQs” runat=”server”>
<ItemTemplate>
<div id=’h<%# DataBinder.Eval(Container, “ItemIndex”) %>’ onclick=’ToggleDisplay(<%# DataBinder.Eval(Container, “ItemIndex”) %>);’>
<%# DataBinder.Eval(Container.DataItem, “question”)%>
</div>
<div id=’d<%# DataBinder.Eval(Container, “ItemIndex”) %>’>
<b>Date Created:</b>
<%# DataBinder.Eval(Container.DataItem, “datecreated”)%><br />
<b>FAQ Ans:</b><br />
<%# DataBinder.Eval(Container.DataItem, “questionanswer”)%>
</div>
</ItemTemplate>
</asp:Repeater>

</form>
</body>
</html>

Server Side (Code Behind)

hideshowdiv.aspx.vb

Import Namespaces
Imports System.Data.SqlClient
Imports System.Configuration.ConfigurationManager

Connection Function

Private Function GetConnection() As SqlConnection
SqlConnection.ClearAllPools()
Dim objCon As SqlConnection = Nothing
Try
objCon = New SqlConnection()
objCon.ConnectionString = ConnectionStrings(“con”).ConnectionString  ‘ConfigurationManager.AppSettings(“connectionString”)
objCon.Open()
Return objCon
Catch ex As Exception
‘ErrorMessage = ex.Message
End Try
Return objCon
End Function

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

If Not Page.IsPostBack Then
BindData()
End If

End Sub
Sub BindData()
‘2. Create the command object, passing in the SQL string
Const strSQL As String = “select * from kbQuestion”

‘Set the datagrid’s datasource to the datareader and databind
Dim resultsDataSet As New DataSet()
Dim myDataAdapter As SqlDataAdapter = New SqlDataAdapter(strSQL, GetConnection())
myDataAdapter.Fill(resultsDataSet)

rptFAQs.DataSource = resultsDataSet
rptFAQs.DataBind()

End Sub

Web.Config

<connectionStrings>
<add name=”con” connectionString=”server=server;database=Test;uid=sa;pwd=1234;pooling=false” providerName=”System.Data.SqlClient”/>
</connectionStrings>

 
1 Comment

Posted by on July 22, 2011 in ASP Dot Net C#

 

Tags: , , , , , , ,

How to access server side variable at client side


So the markup looks something like this

<form id="form1" runat="server">
   <div>
<input type="button" value="Alert" onclick="Print();" />
</div>
<script type="text/javascript">

function Print()

{

alert(<%=QuestionID %>);

}

</script>

</form>

If Not IsPostBack Then

QuestionID = 5

End If

Private _QuestionID As Integer

Public Property QuestionID() As Integer

Get

Return _QuestionID

End Get

Set(ByVal value As Integer)

_QuestionID = value

End Set

End Property

C#

<form id="form1" runat="server">
   <div>
<input type="button" value="Alert" onclick="Print();" />
</div>
<script type="text/javascript">

function Print()

{

alert(<%=QuestionID %>);

}

</script>

</form>
private int _QuestionID;
   public int QuestionID
{
get { return _QuestionID; }
set{_QuestionID = value;}
}
protected void Page_Load(object sender, EventArgs e)
{

QuestionID=9
}

Also you can write in html (body) tags

   <a href="faqs-detail.aspx?QuestionID =<%= QuestionID %>">[Click Here]</a>

 
Leave a comment

Posted by on July 18, 2011 in ASP Dot Net C#

 

Tags: , , , , ,

Abstract Class


The class which can not be instantiated is known as an Abstract Class. This particular article contains the details of an Abstract Class.

Introduction

The class which cannot be instantiated is known as an Abstract Class. That is, an object of it cannot be created. Hence it must be inherited. Let me cite some of the features of an Abstract Class.

Features of an Abstract Class

1. Abstract Class cannot be instantiated.
2. An Abstract Class must be inherited.
3. It may have Concrete Methods.
4. It may have Abstract Methods.
5. An Abstract Method of an Abstract Class must be overridden.
6. An Abstract Class can only contain Abstract Method.

Abstract Class cannot be instantiated.

Error Message

It must be inherited

Output

Abstract Class may have Concrete Method

Output

Abstract Class may have Abstract Method

Error Message

An abstract method of an abstract class must be overridden

Output

An Abstract Method can be present only in Abstract Class

Error Message

Hope this article will be useful.
Thanks!
 
Leave a comment

Posted by on July 17, 2011 in Basic Concepts of oop

 

Tags: , ,