Friday, August 27, 2004

Inside IIS and ASP.NET

This article explains how IIS and ASP.NET communicate, and describes some techniques for intercepting some of this communication. It also shows how ASP.NET is configured to handle requests, and how applications and Web services are handled by default.

http://theserverside.net/articles/showarticle.tss?id=IIS_ASP

Regards,
Mitesh Mehta
Email : miteshvmehta@gmail.com

Tuesday, August 24, 2004

Script Debugging Tips

http://www.gotdotnet.com/team/csharp/learn/whitepapers/How%20to%20debug%20script%20in%20Visual%20Studio%20.Net.doc

A few quick highlights:

o Internet explorer defaults to having script debugging disabled. IE also likes to disable script debugging when you install a new version of IE (example: XP SP2). In IE, go to Tools->Internet Options->Advanced. Prior to Windows XP SP2, the option you needed to uncheck was 'Disable Script Debugging'. In XP SP2, the IE team decided to split this into two separate options - 'Disable Script Debugging (Internet Explorer)' and 'Disable Script Debugging (Other)'. The 'Other' option control script debugging in other applications that use mshtml.dll such as Outlook.

o Try to keep all of your script running in the same script block. IE will sometimes get confused if you have more then one.

o To debug client side script that is in a .ASPX file, you will need to either open the ASPX file from the Running Documents window (called the 'Script Documents' window in Visual Studio 2005), or set a breakpoint by function name (Ctrl-B).


With Best Regards
Mitesh V. Mehta
Email : miteshvmehta@gmail.com
http://cc.1asphost.com/miteshvmehta/

Wednesday, August 11, 2004

Asp.net:Delegates and events


Asp.net:Delegates and events










NET, defines a delegate as a class that holds a reference to a method
oEssentially a typesafe callback method reference (pointer)


In Vb.NET you can define delegate as
Public
Delegate Sub MyCallbackHandler(x as integer)


The signature of the
delegate defines the signature of the methods it can call. For example, the
MyCallbackHandler delegate shown above can be used to refer to void methods that
take a single integer as a parameter:





and Events are declared as
Public Event
MyCallbackEvent As MyCallbackHandler


Events can be used to inform an object that
something significant has happened, and interrupt the flow of control in that
object causing it to execute a method designed for handling the event. An event
provides a component with a hook that an interested client can attach one of its
methods to. When the component wants to indicate that something significant has
happened, it can raise the event and consequently call the associated
methods


Events are closely related to delegates, and rely
on the functionality of multicast delegates for registering methods to be called
when an event is raised






Regards,
Mitesh v. Mehta



Design Days: View State Performance Tips












Design Days: View State Performance Tips

In controls like listbox controls, items added to the list are carried
between client and server via view state... When the list of items become
considerably large it starts hitting the performance and increasing the
traffic between client and server... To avoid this set the EnableViewState
property of the control to be false... By this unnecessary data will not
move back and forth to the server... Though, do note that by doing so your
selected items will no longer remain selected after postback and you will
have to write special code to achieve this functionality...
The same problems are also faced in controls like Datagrid so do ensure that
you use View State judiciously and give enough thoughts while designing your
application...

To see the view state of a page right click on displayed page and 'view
source', here you will see a long line of junk characters for __VIEWSTATE
property... This is the encrypted view state of your controls... Well, that
makes me add one more point the performance... All the viewstate data that
passes to and comes back from server goes through the cycles of encryption
and decryption which in itself is also a costly affair hitting
performance...



Regards,
Mitesh v. Mehta



ASP.Net Server Controls Categories








ASP.Net Server Controls Categories

ASP.Net Server Control can be broadly classified into 4 categories...

1. Intrinsic Controls -These controls correspond to their HTML
counterpart... eg Textbox control, Button control
2. Data-Centric Controls - These controls are used for data display,
binding, modification purposes... They bind to various data sources... e.g..
DataGrid control
3. RichControls - Usually do not have HTML counterparts... These are
usually composite controls which in themselves contain other controls...
e.g. Calendar control
4. Validation Controls - As the name suggest they are used for
validation purposes and can validate many type of user inputs.... e.g.
RegularExpressionValidator

Mitesh Mehta
miteshvmehta@gmail.com

Numeric TextBox - A Simple Way!


Numeric TextBox - A Simple Way!










One of my site visitor ask me a query that he
wants Numeric TextBox in Asp.NET, i suggested him to use javascript but he was
haveing problem on how to write it in javascirpt. i send him this
code

function IsNumeric(e)
{

if (isNaN(e.value) == true)

{
alert("VALUE SHOULD BE
NUMERIC");
e.value =
"";

e.focus();
return
false;
}

else
return true;
}
<INPUT
type="text" name="amount" onkeyup="return IsNumeric(this)">


but then i thought can't we do that in a
simple one line. the thought lead me to Investigate
and i found one can use RegEX to do the same in ONE Line...


<INPUT type="text" name="decimal"
onkeyup=
'this.value=this.value.replace(/[^\d]*/gi,"");' />



Regards,
Mitesh v. Mehta

Web Services


some questions









Still wondering how to get your web server to talk to your client over the internet, eh ? :)
My answers follow:
1.
Being the richest of platforms, the Microsoft platform is not
constrained to just .net or vb for consuming web services. You have the
choice of going for Java which is very capable in the webservices
realm. Then, there is SOAPLite with Perl. Python also has similar
features. Then you can have a browser based client which can consume a
webservice, which you can very well see with ASP.NET webservices, as
the browser on the server machine can act as a client. Now, how are all
these possible brings me to answer question number 2.
2.
Webservices are just a means of having a client consume a service being
exposed on the webserver. While standardizing it, the standards body
went in for an XML based protocol, somewhat akin to XML RPC. To present
a simple outlook of SOAP, the comm. on the internet happens using HTTP.
How would one create a standard means of invoking anything across the
web? The answer, encapsulate the HTTP calls in an XML Structure and
name that structure 'SOAP' and write some proxies and stubs on either
side of the comm. channel. Thats all there is to it. Now, in .NET when
we say ASP.NET webservices, a simple way to consume it is to use SOAP,
and this step is made simple by using Visual Studio. But, having an
ASP.NET webservice in no way undermines your ability to invoke this
webservice from a Linux box with a Perl/SOAPLite -- because its
"Standard." Then there is XML-RPC which you can use. And, then there
are the rest.. err. I mean "REST". For more info on these you could try
these websites.
3. To measure execution speed of your component, there are a couple of approaches
a.
Write to log files with the date/time stamp and then using a simple
vbscript open the log file and parse the times, and draw graphs or
whatever. To make it more persistent, log it to a database. Could
consider MSDE here.
b. You can expose the relevant data as
performance counters and this can be read using the tool "perfmon.exe"
(under WinNT/2K/XP). Again, .NET makes it a breeze to provide/consume
Performance counters in your code.
4. Already answered in the other replies
5.
Just a reminder, in case you are looking for a status/progress kind of
animation, you might want to check out the AVI files in the "graphics"
folder in your VB installation. The samples folder also contains a
sample project which makes use of these videos.
In case these explanations just increase your questions, fire away,
Regards,
Mitesh Mehta

Editable dropdown list box


Editable dropdown list box









An
"editable drop-down list" or a combo-box per se is not supported by any
browser, at least not by IE and Netscape. So having this type of
control is not possible. However, what could be done is to use a
textbox along with a drop-down list and add the contents of the textbox
to the drop-down when the TextChanged event of the textbox fires.
Here's how:
Technique 1:
Using client-side code (note that asp.net controls can also be used here)
<script>
function addToCombo(val, obj)
{
if(val.length > 0)
{
obj.options.add(new Option(val));
}
}
</script>
<input type=text name="txtCombo" onchange="addToCombo(this.value, this.form.selCombo)"><br>
<select name="selCombo"></select>
Technique 2:
Using code-behind (C#)
<asp:TextBox id="txtCombo" runat="Server"/><br>
<asp:dropdownlist id="selCombo" runat="Server"/>
code behind:
private void txtCombo_TextChanged(...)
{
if(txtCombo.Text.Trim().Length > 0)
{
selCombo.Items.Add(new ListItem(txtCombo.Text));
}
}