Useful Substance

IT Resource Center

Achieving No Postback for onClientClick Event – LinkButton

leave a comment »

In aspx page:
OnClientClick="javaScript:return Navigate();

In Javascript:

function Navigate()
{
//do something...
return false; //No Postback
return true; //Postback OK
}

Written by Atul Ashpalia

June 4, 2010 at 10:06 am

Posted in ASP.Net, javaScript

Tagged with ,

Configure applications to access assembly in GAC

leave a comment »

There are times when multiple applications need to access a common business logic or a feature. There are many approaches to expose the common feature to all the applications. One approach is to build a .net assembly and install it to the Global Assembly Cache (GAC). Once the assembly is installed in gac, you need to configure your applications to use it from the GAC.

Below you can see how web/windows/console based and Classic Asp applications can be configured to access the assembly installed in GAC. Read the rest of this entry »

Written by Atul Ashpalia

May 5, 2010 at 11:14 pm

Posted in .Net

Tagged with

Get HTTP Response Code for a Url

leave a comment »

The availability of the website can be checked by submitting a creating a WebRequest and get its Response status code. Below is the sample using C#: Read the rest of this entry »

Written by Atul Ashpalia

May 5, 2010 at 11:02 pm

Posted in ASP.Net

Tagged with

Alternate to using Cursors in SQL for Looping

leave a comment »

1. Create a temporary table.
2. Get the values from your main sql table into this temporary table.
3. Now iterate through the top 1 record from the temporary table, get the row value into a variable and by using the @@ROWCOUNT in the while condition.
4. At the end of the while loop, delete the value from the temporary table which you had set in the variable. Then execute the select statement again to set the @@ROWCOUNT value.
5. The while loop will continue its iteration till all the records from the temporary table gets deleted.

Below is the sample sql script. Have fun!

DECLARE @mytbl As Table (item varchar(10))
insert into @mytbl select items from mySqlTable

declare @item varchar(10)
select top 1 @item=item from @mytbl
WHILE @@Rowcount 0
BEGIN
select count(*) from @mytbl –for testing

Delete from @mytbl where item = @item
select top 1 @item=item from @mytbl
END

Written by Atul Ashpalia

April 1, 2010 at 7:06 pm

Posted in SQL Server

Tagged with

Adjust scroll height of the page having an iframe hosting a different page

leave a comment »

Lets say you have an .asp page that contains an iframe. In the iframe, you are loading another .asp or .aspx page. In that case, how can you make the scroll of the parent page dynamic based on the content of the child page. Read the rest of this entry »

Written by Atul Ashpalia

March 18, 2010 at 5:42 pm

Posted in ASP

Tagged with

Assign value to textarea control in javascript

leave a comment »

Use the below in javascript:
document.getElementById(“textarea_id”).innerHTML = “your_value”;

In ASP, you can wrap this in script tags and using response.write method:
response.write(“<script language=’javascript’>document.getElementById(“textarea_id”).innerHTML = “your_value”;</script>”)

Written by Atul Ashpalia

March 16, 2010 at 10:49 pm

Posted in javaScript

Tagged with

Error (There was an error generating the XML document) when passing DataTable to a WebMethod

leave a comment »

When you get this error, give the Name to the DataTable that you pass as the input parameter to the WebMethod, it will work fine then.

Written by Atul Ashpalia

March 16, 2010 at 10:07 pm

Posted in .Net

Tagged with

Follow

Get every new post delivered to your Inbox.