ITTreats.com
Enter your Search term and Hit "Enter"

Sat, 20 Mar 2010 12:12:57 PM +00:00

Latest 'ITTreats'


Paginating in ASP

Paginating in ASP

Pagination in asp, plays major roll when you want to display page wise results , what if the recordset size is more or huge, in that case the processing of the page will become slow…

For that here is the query , which will really help you

the following query is MSSQL query

For example if you want employee name whose
salaries are 2nd highest and 1oth highest

Now,

step 1 :select *, ROW_NUMBER() over ( salary desc) as ROWID from emp

step 2 : supply the above query as sub query

select * from ( select *,ROW_NUMBER() over (salary desc) as ROWID from emp ) where rowid between 2 and 10

thats it .. now you will get emploee list from 2nd highest salary to 10th highest salary ,,,,

by making use of the above query in pagination purpose, then your page will never slow down becoz, we are putting only 10 to 100 rows at max ,

Creating and Using Own Templates using ASP

Creating and Using Own Templates using ASP

When ever the scripts on your pages will become complex, Templates are the best solution.

working on ASP Templates is quite easy,

1. Stick to page layout
eg:. pregare a static html page with your requirements
2. change the content part of each division to one standard identification string
eg:.

<div id='leftpanel'>
    <ul>
          <li>1</li>
<li>1</li>
<li>1</li>
<li>1</li>
<li>1</li>
</ul>
</div>

where ul is the dynamically generated content

change it to
<div id=’leftpanel’>
<!-leftpanel->
</div>

3. Now write a function with the final html code

Function htmltemp()
template = “”
template = template & “<!-title->”
template = template & “”
template = template & createBody()
template = template & “”
template = template & “”
htmltemp = template
End Function

FUNCTION createBody()

bodytext =bodytext &”<!-header->”
bodytext =bodytext & “<!-menunavigation->”
-
-
-
createBody=bodytext
End Function

like this go on creating functions for the necessery blocks and combine them to form a dynamic HTML content

finally integrate this in the page where needed as shown below :

File : finaltemplate.asp

<% thetitle = “HTML Template”
thebody = “<CENTER> This is the template! </CENTER>”

template = htmltemp()
template = Replace(template, “<!-title->”, thetitle)
template = Replace(template, “<!-body->”, thebody)
Response.Write template

Function htmltemp()
template = “<HTML>”
template = template & “<TITLE><!-title-></TITLE>”
template = template & “<BODY>”
template = template & “<!-body->”
template = template & “</BODY>”
template = template & “</HTML>”
htmltemp = template
End Function

%>

How to Make Read only Check Boxes

How to Make  Read only Check Boxes

How we can make a Chek box readonly? Even if we provide Readonly attribute you still can check or uncheck the checkbox..

then how we can make a CheckBox ReadOnly ??
Here is the simple solution,  we can do this  with Javascript. here is how it goes

write a onclick even for the desired checkbox, and  check weather it is checked , if it is check then make that checked as false vice versa

<input type=\”checkbox\” value=\”xyz\” checked onclick=\”javascript:if (this.checked==true) this.checked=false; else this.checked=true;\” />

Here is the example Below :

Try to Uncheck Me :

Simple is\’t it ??

Strip HTML tags ,Script blocks,Forms, style blocks using Regex in C#.net

Strip HTML tags ,Script blocks,Forms, style blocks  using Regex in C#.net

Many times in Many cases we may come across this problem how to strip HTML Tags,

How to Remove Script Blocks ? How to remove Form Blocks and how to remove Style sheet blocks ?

for those questions here is the simple and best answer More . . .