Search content within the blog

Sunday, October 17, 2010

Thread.Join

What is Thread.Join() in threading ?
There are two versions of Thread.Join :-
. Thread.join().
. Thread.join(Integer) this returns a Boolean value.

The Thread.Join method is useful for determining if a thread has completed before starting another task. The Join method waits a specified amount of time for a thread to end. If the thread ends before the time-out, Join returns true; otherwise it returns False. Once you call Join, the calling procedure stops and waits for the thread to signal that it is done.

Example you have "Thread1" and "Thread2" and while executing 'Thread1" you call "Thread2.Join()".So "Thread1" will wait until "Thread2" has completed its execution and the again invoke "Thread1".Thread.Join(Integer) ensures that threads do not wait for a long time. If it exceeds a specific time which is provided in integer the waiting thread will start.

Monday, October 11, 2010

Add a Row Number to the GridView

Here’s a simple way to add a Row Number to the GridView. Just add the following tags to your section of your GridView

Columns>
<asp:TemplateField HeaderText="RowNumber">
<ItemTemplate>
<%# Container.DataItemIndex + 1 %>
</ItemTemplate>
</asp:TemplateField>
...
</Columns>
and you will get the following output

Retrieve DIV value in ASP.NET using jQuery

In this example, we will see how to retrieve and display the value of a div in an alert box, on the button click event.


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Retrieve Value of DIV in ASP.NET</title>
<script type="text/javascript"
src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js"></script>

<script type="text/javascript">
$(function() {

$('input[id$=btnClick]').click(function () {
var divValue = $('#div1').html();
alert(divValue);
return false;

});

});

</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<div id="div1">Div Sample content</div><br />
<asp:Button ID="btnClick" runat="server" Text="Click" />
</div>
</form>
</body>
</html>