Microsoft Dot Net Master
Friday, July 15, 2011
Which attribute is used in order that the method can be used as WebService ?
What the different phase/steps of acquiring a proxy object in Webservice ?
What is WSDL?
What is DISCO ?
What is UDDI ?
What is a Web Service ?
What is ObjRef object in remoting ?
implements the interface ISerializable, and can be marshaled by value. The ObjRef knows
about :-
√ location of the remote object
√ host name
√ port number
√ object name.
What is marshalling and what are different kinds of marshalling ?
What is Asynchronous One-Way Calls ?
How can we call methods in remoting Asynchronously ?
What are LeaseTime, SponsorshipTime, RenewonCallTime and LeaseManagerPollTime?
Is it a good design practice to distribute the implementation to Remoting Client ?
In CAO model when we want client objects to be created by “NEW” keyword is there any precautions to be taken ?
Are CAO stateful in nature ?
by client on server can be retrieved again with correct value.
What are the ways in which client can create object on server in CAO model ?
√ Activator.CreateInstance().
√ By Keyword “New”.
What is fundamental of published or precreated objects in Remoting ?
What are the situations you will use singleton architecture in remoting ?
What are two different types of remote object creation mode in .NET ?
Which class does the remote object has to inherit ?
(I)
What is .NET Remoting ?
What is an application domain?
Thursday, July 14, 2011
Difference between Stored procedures and User Defined functions
A stored procedure is a program (or procedure) which is physically stored within a database. They are usually written in a proprietary database language like PL/SQL for Oracle database or PL/PgSQL for PostgreSQL. The advantage of a stored procedure is that when it is run, in response to a user request, it is run directly by the database engine, which usually runs on a separate database server. As such, it has direct access to the data it needs to manipulate and only needs to send its results back to the user, doing away with the overhead of communicating large amounts of data back and forth.
User-defined function
A user-defined function is a routine that encapsulates useful logic for use in other queries. While views are limited to a single SELECT statement, user-defined functions can have multiple SELECT statements and provide more powerful logic than is possible with views.
In SQL Server 2000
User defined functions have 3 main categories
- Scalar-valued function - returns a scalar value such as an integer or a timestamp. Can be used as column name in queries
- Inline function - can contain a single SELECT statement.
- Table-valued function - can contain any number of statements that populate the table variable to be returned. They become handy when you need to return a set of rows, but you can't enclose the logic for getting this rowset in a single SELECT statement.
- UDF can be used in the SQL statements anywhere in the WHERE/HAVING/SELECT section where as Stored procedures cannot be.
- UDFs that return tables can be treated as another rowset. This can be used in JOINs with other tables.
- Inline UDF's can be though of as views that take parameters and can be used in JOINs and other Rowset operations.
- Of course there will be Syntax differences and here is a sample of that
CREATE PROCEDURE dbo.StoredProcedure1 /* ( @parameter1 datatype = default value, @parameter2 datatype OUTPUT ) */ AS /* SET NOCOUNT ON */ RETURN
CREATE FUNCTION dbo.Function1 ( /* @parameter1 datatype = default value, @parameter2 datatype */ ) RETURNS /* datatype */ AS BEGIN /* sql statement ... */ RETURN /* value */ END
Thursday, July 7, 2011
How to add javascript validation event to textbox inside Gridview?
Code:
<script type = "text/javascript" language = "javascript">
function numeralsOnly(evt)
{
evt = (evt) ? evt : event;
var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));
if (charCode > 31 && (charCode < 48 || charCode > 57) && (charCode != 46))
{
alert("Enter numerals only in this field!");
return false;
}
return true;
}
</script>
the way in which it can be specified with a textbox inside a gridview:
<asp:TextBox ID="txtProjBudget" onkeypress="return numeralsOnly(event)" runat="server" Text='<%# Eval("Proj_Exp") %>' Width="103px"></asp:TextBox>
Friday, July 1, 2011
How To Format DateTime In GridView Boundfield And Template Columns
Character | Description | Date Format | Example |
Y or y | Month and year | MMMM,YYYY | May 2011 |
d | Short Date | MM/dd/yyyy | 15/1/2011 |
D | Long Date | dddd,MMMM dd,yyyy | Sunday, May 15, 2011 |
f | Full date and time without secs | dddd,MMMM dd,yyyy HH:mm | Sunday, May 15, 2011 4:23PM |
F | Full date | dddd,MMMM dd,yyyy HH:mm:ss | Sunday, May 15, 2011 4:23:45PM |
g | Date time without sec | MM/dd/yyyy HH:mm | 5/15/2011 4.25 PM |
G | Full date | MM/dd/yyyy HH:mm:ss | 5/15/2011 4.25:35 PM |
M or m | Month and day | MMMM dd | May 15 |
R or r | Full date with GMT | ddd,dd MMMM yyyy HH:mm:ss GMT | Sun,15 May 2011 4.25:35 GMT |
s | Sortable Date time | yyyy-MM-ddTHH:mm:ss | 2011-05-15T16:33:55 |
t | Short time | HH:mm | 4:56 PM |
T | Long Time | HH:mm:ss | 4:56:45 PM |
u | Sortable DateTime Pattern using universal time | yyyy-MM-ddTHH:mm:ssz | 2011-05-15T16:33:55z |
U | Long Date | ddd,dd MMMM yyyy HH:mm:ss | Sunday, May 15, 2011 4:54:10 PM |
C | Currency Format | $00.00 | $10.00 |
D | Decimal Format | 10 | 10 |
Now we will implement these formats in our gridview for this first bind the date
values from your database and design your aspx page like this
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Gridvew Date format</title> </head> <body> <form id="form1" runat="server"> <div> <asp:GridView runat="server" ID="gvdetails" DataSourceID="dsdetails" AllowPaging="true"AllowSorting="true" AutoGenerateColumns="false"> <RowStyle BackColor="#EFF3FB" /> <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /> <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" /> <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /> <AlternatingRowStyle BackColor="White" /> <Columns> <asp:BoundField DataField="Date1" HeaderText="Date1" HtmlEncode="false" DataFormatString="{0:s}" /> <asp:BoundField DataField="Date2" HeaderText="Date2" HtmlEncode="false" DataFormatString="{0:D}" /> <asp:BoundField DataField="Date3" HeaderText="Date3" HtmlEncode="false" DataFormatString="{0:m}" /> <asp:BoundField DataField="Date4" HeaderText="Date4" HtmlEncode="false" DataFormatString="{0:d}" /> <asp:BoundField DataField="Total" HeaderText="Total" HtmlEncode="false" DataFormatString="{0:C2}" /> </Columns> </asp:GridView> <asp:SqlDataSource ID="dsdetails" runat="server" SelectCommand="select * from DateFormat" ConnectionString="<%$ConnectionStrings:dbconnection %>"> </asp:SqlDataSource> </div> </form> </body> </html> |
<connectionStrings> <add name="dbconnection" connectionString="Data Source=SandeepRauniyar; Integrated Security=true;Initial Catalog=MySampleDB"/> </connectionStrings > |
If you want to use these date string formats in itemtemplate field we
need to bind fields like this
<asp:TemplateField HeaderText="Date1"> <ItemTemplate> <asp:Label ID="lblDate" runat="server" Text='<%#Eval("Date1","{0:y}") %>'/> </ItemTemplate> </asp:TemplateField> |