Académique Documents
Professionnel Documents
Culture Documents
Forms in ASP.NET
Web pages in ASP.Net are called ASP.NET Web Forms which have certain server
controls such as text, dropdown list, checkboxes, and buttons. An ASP.NET Web
Form looks similar to the web forms in HTML. The only difference is that in ASP.NET,
the Web Forms runs at the server side and in HTML the web forms runs at the client
side. Apart from this difference an ASP.NET Web Form has more features than an
ordinary HTML web form such as:
ASP.NET user controls have extension .acsx and can be used in any page after
they are made (similar to server-side includes). It is like a “black box”.
You can create a user control by using the Register directive. This process is called
registering the user control. For instance, you can use this code to register a user
control:
The TagPrefix is the exclusive namespace provided to the user control so that
multiple ASP.NET User Controls with similar name can be discriminated from each
other. The TagName is the name of the user control and the Src is the virtual path to
the user control. After registering the user control you can place the tag of the user
control in an appropriate location on the web form. You have to include the
runat=”server” attribute with the tag.
SOME ADMINISTRATION PART
When you install IIS after .NET framework, you have may have to do the following
things
aspnet_regiis –I
For Error: A name was started with an invalid character. Error processing resource
'http://localhost/IssueTracker/Default.aspx'. Line...
Go to IIS Manager > Your Virtual Folder > Properties > ASP.NET Tab > Set the
ASP.NET version to 2.(……)
It seems like Visual studio 2005 and the web application pool running ASP.NET 2.0 are
having a conflict over the temporary folder.
The workaround I have got for now is:
- If you have visual studio 2005 is open, close it
- Go tot the ASP.NET temporary folder for v2.0 of the framework
<Windows dir>\Microsoft.Net\Framework\v2.0<extra numbers>\Temporary ASpNET
pages
- Remove the folder for your application (or all of them)
- Reset IIS (on a command line window, >iisreset) [not always needed, but I had to use it
sometimes]
- First Browse your page from IE (http://localhost/your app)
- Then reopen Visual studio
HTMLDocument can take the html file from webBrowser control of Visual Studio.
HTMLDocument.All Property returns a collections of all HTML tags and can be parsed
in a foreach loop. For example if used with a normal HTML page. First it will show the
full HTML tag part (that would cover the entire doc itself), then it would show for HEAD
part , then BODY…..and so on.
When you are using these, do not forget to flush() and close(). Otherwise it will not work.
Suppose you want to read from a stream named “str” and write it
to a file c:\newfeed.xml.
Here “str” is the inputstream from where we have to read. First we read
10,000 bytes from the “str” and put in the buffer(0 denotes—we are using the buffer from
starting). This read operation automatically takes the position to 10,000 in the stream.
bytesRead contains 10000 (the nos. of bytes we have read). Then we write the contents of
the buffer to the outputstream “fstr” (0 denotes we are reading from staring of buffer).
While writing any url (for instance the value of key-value pair) in the web/app.xml
replace & with & (encoding).
Eg: http://amdus:Py197eWkl@feedpartnerus.pricerunner.com/Feed.jsp?
f=amdus&categories=682&show=properties&alllinks=1&limit=200
has to be written as
http://feedpartnerus.pricerunner.com/Feed.jsp?
f=amdus&categories=682&show=properties&alllinks=1&limit
=200
READING FROM AND WRITING TO A FILE (with some changes)
//FileMode has to be "open" so that file just got is opened for reading
while (!rdr.EndOfStream)
{
string line = rdr.ReadLine(); //reading line by line and storing it
line = line.Replace("™", ""); //in string so that string functions
/////////can be done
wtr.WriteLine(line);
}
wtr.Flush(); ///to dump the contents of “wtr” to “c:\destination_file”
wtr.Close();
fstr_for_replace.Close();
REGISTERSTARTUPSCRIPT / REGISTERCLIENTSCRIPTBLOCK
So RegisterStartupScript is used when some script has some dependencies on the server
controls otherwise it will show object not found error.
SYNTAX:
String Script = "";
//Script += "<script type='text/javascript'>\n";
Script += "alert('The first statement of javascript');\n";
Script += "alert(document.getElementById('TextBox1').value);\n";
Script += "function checkNoSelection() {\n";
Script += "if ((document.getElementById('rb1').checked == false) &&
(document.getElementById('rb2').checked == false) &&
(document.getElementById('rb3').checked == false))\n";
Script += "{\n";
Script += "alert('Please select a choice');\n";
Script += "}\n";
Script += "}\n";// end of function1
Script += "function checkTextBox1() {\n";
Script += "if (document.getElementById('TextBox1').value == '') {\n";
Script += "alert('Please fill TextBox1');}};\n";//end of if,second func
//Script += "</script>\n";
if (!Page.ClientScript.IsStartupScriptRegistered("clientscript"))
{
Page.ClientScript.RegisterStartupScript(this.GetType(),
"clientscript", Script, true);
/// true adds <script> tags
}
Button1.Attributes.Add("onclick","checkNoSelection();checkTextBox1();");
-----------------------------------------------------------------------
Practical Scenario: A Datatable is returned from the back-end. You want to perform
operations in some selected rows. This is done through Checkbox. To perform some
operations, first add a column to DataKeyNames property. This acts like a Primary Key.
This is very important.
To do all of the above dymanically (through cs file), make separate class for template
which derives from ITemplate. It will control the Checkbox control
-------------------------------------------------------------------------------------------------------
DEBUGGING IN ASP.NET
Debugging only a particular function (like a button click) that also which does not
executes directly (like a class library……..WebPart). Use "attach to process" debug
process, then select the concerned process….then attach a breakpoint…… then do "step
over" to move on. For Webparts, process could be wss.
-------------------------------------------------------------------------------------------------------
To install SQL Server Reporting Services first install SQL Server 2005 Express
with Advanced Services as it has reporting services/SQLExpress Database
Engine/Management Studio in it. The only problem is it does not have SSRS/SSIS
templates for Visual Studio. To achieve that uninstall SQL Server 2005 from Add
Remove programs –> Select Workstation Components (Do not uninstall the
DatabaseEngine and Reporting Services) and install the SQL server 2005
Standard/Enterprise Edition Client Tools. (\SQL Server 2005
Enterprise\Tools\Setup.exe)Your purpose will be fulfilled however SQLExpress
Reporting Services do not have the Report Builder (does not matter )
3)If you have any Sym Key/Signing issue, just go to SQL Server Config. Manager,
Delete all Encryped keys/data. It ll work out fine.
SSIS
Click File “Save copy of package as..” Choose SSIS package store or Choose
SQL Server. If you choose SSIS package store, the package will be
stored as /File System/Package1. If you choose SQL Server, the
package will be stored as /MSDB/Package1.
2)format-->auto format
3)format-->auto layout
7)double clicking on "join" of two task in "Data flow" gives data flow path editor
(contains mapping metadata). Try changing its "name" and "path annotation"
8)Check the "Data Viewer" tab in "data flow path editor". Its cool. kinda Debugger.
9)Enable logging thru SSIS menu. give the provider (flat file). You can even view in
the "Log Events" window thru View-->Other Windows.
Unpivoting a Table means converting a row having multiple fields to multiple rows.
Q-) why SSIS package stored in server pc cannot be run through Mgmt Studio in
Client PC (w/o having SSIS installed in the client PC)
A-) When you execute the package from Management Studio, it runs the package on
the client. Since you don't have SSIS server
components on workstation, you can't run the package this way from the
workstation.
You can however schedule the package as a job on the server from Management
Studio on workstation, and then start this job -
also from workstation. The job and the package will run on server in this case.
Step1)http://msdn.microsoft.com/en-us/library/aa337083.aspx
Step2)http://mohansmindstorms.spaces.live.com/Blog/cns!69AE1BEA50F1D0E7!
213.entry?action=post&wa=wsignin1.0
Step3)http://www.etiennek.com/2008/01/16/connect-to-ssis-service-on-machine-
sqlserver01-failed/
• SQL Server Agent is not found in SQLEXPRESS
1) Right Click --> Add Job --> Step-->New Step-->SSIS Package --> Give Package details. -->
done.
2) use msdb
go
Three ways to execute SSIS Package thru code in Webservice hosted in the same SQL
Server.
a) app.LoadPackage("D:\Subhasis\ISProject2\ISProject2\Package.dtsx", null);
so use sp_start_job stored procedure. Thats the only way till now.
http://blogs.msdn.com/michen/archive/2007/03/22/running-ssis-package-programmatically.aspx
http://www.codeproject.com/KB/aspnet/Deployment_SSIS_NET.aspx
(The webserver needs to have Integration Service installed (not the whole SQL Server) to use the
SSIS Object model and call SSIS Package programatically through its object model. Calling SSIS
package through its Object model has the advantage of passing parameters to it)
Use of xp_cmshell
GO
-- To update the currently configured value for advanced options.
RECONFIGURE
GO
GO
RECONFIGURE
GO
1)
select h.SalesOrderNumber, h.ShipDate, h.CustomerID, d.OrderQty,
d.ProductID, d.LineTotal FROM
Sales.SalesOrderHeader h
JOIN
Sales.SalesOrderDetail d on d.SalesOrderID=h.SalesOrderID
where
h.ShipDate BETWEEN convert(VARCHAR(10),'01/01/2002',103) AND
convert(VARCHAR(10),'01/05/2002',103)
ORDER BY
h.ShipDate, h.SalesOrderNumber //There is a date in the query
2)
SELECT CONVERT(VARCHAR(10), GETDATE(), 103)
3)
http://www.sql-server-helper.com/tips/date-formats.aspx
To call SSIS package remotely from client and with parameters ...great ..what I was looking for
source:https://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=3400941&SiteID=17
(Very good)
@Param1 nvarchar(50)
as
begin
end
SqlConnection jobConnection;
SqlCommand jobCommand;
SqlParameter jobReturnValue;
SqlParameter jobParameter;
int jobResult;
jobCommand.CommandType = CommandType.StoredProcedure;
jobParameter.Direction = ParameterDirection.Input;
jobCommand.Parameters.Add(jobParameter);
jobParameter.Value = TextBox1.Text;
jobConnection.Open();
jobCommand.ExecuteNonQuery();
jobConnection.Close();
namespace CSharpFeatures
{
class Program
{
static void Main(string[] args)
{
List<Customer> list = new List<Customer>();
list = GetCustomers();
c = new Customer();
c.Name = "Ajeet";
c.City = "Hapur";
c.CustId = 3;
custList.Add(c);
c = new Customer();
c.Name = "Mudit";
c.City = "Noida";
c.CustId = 4;
custList.Add(c);
return custList;
}
}
public class Customer
{
private string name;
private string city;
private int custId;
Passing Parameters
Workflows would have limited usefulness without the ability to receive parameter input. Passing
parameters to a workflow is one of the fundamental mechanisms that permit you to affect the
outcome of the workflow.
The preceding example writes a simple string constant to the Console. Let’s now modify that
example so that it uses input parameters to format the string that is written. The parameters will be
passed directly from the host console application.
Notice that the key to each parameter in the Dictionary is an exact match to one of the workflow
public properties. This is not an accident. In order for the parameters to make their way into the
workflow, the names must match exactly, including their case. Likewise, the Type of the parameter
value must match the expected Type of the property. In this example, both properties are of type
String, therefore a string value must be passed in the Dictionary.
The only other required change is to actually pass the Dictionary object to the workflow. This is
accomplished with an overloaded version of the CreateWorkflow method as shown here:
WorkflowInstance instance
= workflowRuntime.CreateWorkflow(typeof(HelloWorkflow.Workflow1),
wfArguments);
When this example application is executed, the results indicate that the parameters are
successfully passed to the workflow:
Hello Bruce, did the workflow succeed?
Press any key to exit
Calculator Example in WF
C:\Documents and
Settings\Fun Zone\My Documents\Visual Studio 2005\Projects\WorkflowCalc.zip
Points to note:
Example :
public static DependencyProperty SalesItemIdProperty
= System.Workflow.ComponentModel.DependencyProperty.Register(
"SalesItemId", typeof(Int32), typeof(Workflow1));
/////Workflow1 is the name of the CLASS having this
dependency property
/// <summary>
/// Identifies the item to sell
/// </summary>
- Custom activity (simple ones) should be derived from base Activity class rather than
base SequenceActivity class (this one is by default when you add a activity) as the latter
is a composite activity and enables you to host other child activity. No harm in using it
but can confuse the user of the custom activity.
- While Using Custom Activity, start using dependency properties (using snippets) from
the beginning. Override the execute method by simply writing “override” and using
intellisense.
-Notice that the private instance variables used in the CodeActivity example have been
omitted from this workflow(Custom Activity example). Those variables are needed in
that example since they are used to pass state between each execution of a CodeActivity
(by CodeActivity setting the values of private variables and If-else using them) . In this
example, the same data is passed directly between activities using their bound
dependency properties. This eliminates the need for the private instance
variables.
-After making the custom activites, you have to build the workflow – to make Custom
Activites show up in the Toolbox.
After adding event handlers, the workflow runtime engine is started by calling the
StartRuntime method. Calling this method isn’t strictly required in this example since
the runtime will automatically start when you create your first workflow. This example
doesn’t add any core workflow services, but if it did, they would be registered with the
workflow runtime prior to calling the StartRuntime method.
If doSomething() throws an exception - conn will never get explicitly closed. Here is
how this can be corrected:
SqlConnection conn = new SqlConnection(myConnectionString);
try
{
conn.Open();
doSomething(conn);
}
finally
{
conn.Close();
}
or
using (SqlConnection conn = new SqlConnection(myConnectionString))
{
conn.Open();
doSomething(conn);
}
Did you notice that in the first example we called conn.Close() explicitly while in the
second one we make the compiler generate an (implicit) call to conn.Dispose()
immediately following the using block? The C# using block guarantees that the Dispose
method is called on the subject of the using clause immediately after the block ends.
Close and Dispose methods of Connection object are equivalent. Neither one gives you
any specific advantages over the other.
Listing 1
Listing 2
Listing 3
// The connection string is the same as in Listing 1 so no new pool is created.
SqlConnection conn = new SqlConnection();
sqlConnection.ConnectionString =
"Server=localhost;Database=test;User ID=joydip;Password=joydip;Trusted_Connection=False";
sqlConnection.Open();
Browser Request HTTP Handler Factory ASP.NET Page Life Cycle Begins
2) Any data stored by the developer using the Viewstate property [Key-Value]
Page LifeCycle
1. PreInit - This is the only event where programmatic access to master pages and
themes is allowed. Dynamic Controls should be created here. Controls created
during Design time(except controls in MasterPage) are initialized here.
2. Init
3. InitComplete
4. LoadViewState
5. LoadPostbackdata – This is responsible for loading postback data. Like something
written on the Textbox, Checkbox checked etc. Note: ViewState is not
responsible for this. Try this with ViewState off and it will work.
6. PreLoad
7. Load
8. RaisePostbackEvent
9. LoadComplete
10. PreRender
11. PreRenderComplete
12. SaveViewState
13. SaveControlState
14. Render
15. UnLoad
• It contains a single Label control (lbl) with its “Text” property set to
“statictext”
• It contains a Button control (btnA) with code in its event handler that sets
the “Text” property of “lbl” to “dynamictext”
• It contains a Button control (btnB) whose purpose is to cause a page
postback
Now, let us examine what will happen during the page life cycle.
ViewstateDemo.zip
Disabling Viewstate would obviously reduce Viewstate size; but, it surely kills the
functionality along the way. So, a little more planning is required…
Consider the case where you have a page with a drop down list that should display
the countries of the world. On the “Page_Load” event handler, you bind the drop
down list to a data source that contains the countries of the world; the code that
does the binding is wrapped inside a “!IsPostback” condition. Finally, on the page,
you have a button that when clicked should read the selected country from the drop
down list. With the setup described above, you will end up with a large
__VIEWSTATE field. This is due to the fact that data bound controls (like the drop
down list) store their state inside the Viewstate. You want to reduce Viewstate; what
options do you have?
If you implement Option 1, you will reduce the Viewstate alright, but with it, you will
also lose the list of countries on the first postback of the page. When the page
first loads, the code in the “Page_Load” event handler is executed and the list of
countries is bound to the list. However, because Viewstate is disabled on the list, this
change of state is not saved during the “SaveViewState” event. When the button
on the page is clicked causing a postback, since the binding code is wrapped inside a
“!IsPostback” condition, the “LoadViewState” event has nothing saved from the
previous page visit and the drop down list is empty. If you implement Option 2, you
will reduce the Viewstate size and you will not lose the list of countries on postback.
However, another problem arises: because the binding code is now executed
at each “Page_Load”, the postback data is lost upon postback, and every
time, the first item of the list will be selected. This is true because in the page
life cycle, the “LoadPostbackdata” event occurs before the “Load” event. Option
3 is the correct option. In this option, you have done the following:
Since the “Init” event occurs before the “LoadPostbackdata” in the page
life cycle, the postback data is preserved upon postbacks, and the selected
item from the list is correctly preserved.
Now, remember that in Option 3, you have successfully reduced the Viewstate size
and kept the functionality working; but, this actually comes at the cost of rebinding
the drop down list at each postback. The performance hit of revisiting the data
source at each postback is nothing when compared with the performance boost
gained from saving a huge amount of bytes being rendered at the client’s
__VIEWSTATE field. This is especially true with the fact that most clients are
connected to the Internet via low speed dial up connections
First Way
// Creates a new Outlook Application Instance
Microsoft.Office.Interop.Outlook.Application objOutlook = new
Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.Inspector objInspector;
// Creating a new Outlook Message from the Outlook Application Instance
Microsoft.Office.Interop.Outlook.MailItem mi =
(Microsoft.Office.Interop.Outlook.MailItem)
(objOutlook.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailIte
m));
objInspector = mi.GetInspector;
mi.To = txtProdOwner.Text;
mi.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML;
mi.Subject = hdnItemCode.Value + " - " +
hdnItemversion.Value + " : " + hdnItemDescription.Value;
mi.HTMLBody ="<span style='font-size:10.0pt;font-
family:\"Arial\",\"sans-serif\"'>"+
//fire outlook
mi.Display(true);
Second way
The other way is to use mailto HTML attribute but you can only send simple
unformatted mails and not HTML mails using mailto.
USING LOG4NET
In this example, I have configured three types of logger. In practical apps one is
enough. (refer documentation)
This should be done at class level. In a practical app., you can do it a base page from
where all page would extend.
log4net.Config.XmlConfigurator.Configure(new
System.IO.FileInfo("C:\\Subhasis\\Testing\\Testing\\log4net.xml"));
Use Expresso to make Regular Expressions and use it with Editplus to ‘find n replace’
any pattern.
USE AdventureWorks;
GO
DECLARE @MyMsg VARCHAR(50)
SELECT @MyMsg = 'Hello, World.'
GO ---- @MyMsg is not valid after this GO ends the batch.
identity column creates a numeric sequence for you. Default is 1,1 (seed,increment)
If you cannot remember the syntaxes of SQL, Stored proc….Use the Template Explorer.
Click on ViewTemplate Explorer. Drag n Drop a template. It even shows how to
execute the stored proc.
DESIGN PATTERNS
2)Proxy Pattern: Object1 representing Object2. (the actual work is done by the Object2).
This is used to Implement Lazy Loading
3)Singleton Pattern: Class ensures that at a time only one instance is present.
Implemented by having a private/protected constructor (so that a new instance is not
initialized using new()) and an static private variable of its type. Practically used in Load
balancing servers.
Microsoft Enterprise Library
2)DataAccess: DatabaseFactory.CreateDatabase(“instancename”);
Db.ExecuteScaler , Db.ExecuteDataset, Db.ExecuteReader(“StoredProcname-Params”)
..encrypting connection string
DELEGATES IN C# (EXPLAINED)
http://www.codersource.net/csharp_delegates_events.html
If a delegate stores the reference of more than one function, it is called a multicast
delegate. Multicast delegate return type is always void.
The line above means “fx” stores a reference to function “InvertX’ and so-on.
CACHING IN ASP.NET (V.IMP)
Caching is done by adding a directive on the top of the page <%@OutputCache. The
duration for which it is to be cached is specified in the durarion attribute and it is
mandatory (there is no default value). The best way to test is display the current
date/time.
Eg:
<%@ OutputCache Duration=20 VaryByParam="none" %>
<div>
<%=DateTime.Now.ToString() %>
</div>
ASP.NET implements this through Output Cache Engine. First the page is checked here
before dynamically generated.
“VaryByParam” attribute is used to cache based on parameters (either GET or POST).
Example /ProductInfo.aspx?PartNo=4 will check for cached page for that particular
details of a PartNo, if VaryByParam=”PartNo” is set, otherwise it will show the output of
previously opened page for any PartNo. This attribute is also mandatory.
As the name suggests Icomparable makes an object of a class (say Person) comparable to
another Person object based on some logic. The Person class has to implement
Icomparable interface
Where as IComparer is used to make custom comparer and is passed to the sort method
of Lists etc. (listPersons.sort(new FirstNameComparer());
• In-place compilation This option performs the same compilation that occurs during dynamic
compilation. Use this option to compile a Web site that has already been deployed to a production
server. (copying the aspx and aspx.cs directly to the server without precompiling)
• Non-updateable full precompilation Use this to compile an application and then copy the
compiled output to the production server. All application code, markup, and UI code is compiled
into assemblies. Placeholder files such as .aspx pages still exist so that you can perform file-
specific tasks such as configure permissions, but the files contain no updateable code. In order to
update any page or any code you must precompile the Web site again and deploy it again.
UI elements such as .aspx pages and .ascx controls retain all their markup, UI code, and inline
code, if any. You can update code in the file after it has been deployed; ASP.NET will detect
changes to the file and recompile it. Note that code in a code-behind file (.vb or .cs file) built into
assemblies during precompilation, and you therefore cannot change it without going through the
precompilation and deployment steps again.
JQuery
To use jQuery you have download the jquery.js file and and jQuery-vsdoc.js (for Visual
Studio) both, otherwise it wont work. And to use intellisense you have to install a hotfix
in VS for jQuery
Just realized jQuery-vsdoc.js does not work properly so use jQuery-vsdoc2.js. it works
perfect
$(document).ready(function() {
$("table tr:nth-child(even)").addClass("even");
});
is better than
window.onload = function() {
$("table tr:nth-child(even)").addClass("even");
};
As the former waits until the DOM tree is made while the latter waits until the full page is
loaded with all images etc (making it longer to wait before the script is executed)
To make things simpler, filter selectors are easily identified because they all
begin with a colon character (:) or a square bracket character ([). Any other selector
can’t be used inside the :not() filter
If you are using jQuery to handle click of a button you have to write “return false;”
otherwise it will bubble up the DOM tree and the output will not be visible.
Use of $.each() function to parse array,obj,array of objects (4 examples shown)
$.each(arr1, function(n, value) {
$("#someElement").append(value + "<br/>");
});
Using jQuery for AJAX is very simple. Use it with any method of anypage.aspx. The
conditions are
1) That method should be “static”
2) That method should have [Webmethod] Attribute
3) That method should be accesible (public) from the calling page.
That anypage can even return a custom object say “objPerson”. Every detail of JSON
serialization is taken care by jQuery.
Note: Use Fiddler for any error/debugging. It helped me a long way. If you are getting
any error in Visual Studio, Its probably due to improper jQuery syntax.
Below is a “hello world”. It gets a “custom object”. Some points to note are
a) we are using POST to make it more secure as GET requests are vulnerable to XSS
attacks
b) No params requests (GET requests) are passed as “{}”
c)The response is always a object with property “d”. This feature was there in .NET 3.5
and was introduced to make it more secure.
$(function() {
$.ajax({
type: "POST",
url: "AjaxPageMethods.aspx/GetObject",
data: "{}",
contentType: "application/json;charset=utf-8",
dataType: "json",
success: function(msg) {
$("#Result").text(msg.d.CategoryId +
msg.d.CategoryName);
},
error: function() {
alert("Sorry, The requested property could not be
found.");
}
}
);
Some Links
http://encosia.com/2008/03/27/using-jquery-to-consume-aspnet-json-web-
services
http://encosia.com/2008/06/05/3-mistakes-to-avoid-when-using-jquery-
with-aspnet-ajax
http://encosia.com/2009/02/10/a-breaking-change-between-versions-of-
aspnet-ajax/#comment-34045
http://encosia.com/2008/04/16/why-do-aspnet-ajax-page-methods-have-to-
be-static
http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-
ajax-page-methods
http://mosesofegypt.net/post/2008/04/GridView-Grouping-Master-Detail-
Drill-Down-Using-jQuery-AJAX.aspx
HttpWebRequest req =
(HttpWebRequest)WebRequest.CreateDefault(new
Uri(@"http://localhost/WebService123/WebService1.asmx"));
req.ContentType = "text/xml; charset=utf-8";
req.Method = "POST";
req.Accept = "text/xml";
req.Headers.Add("SOAPAction",
@"http://subhasisrout.org/GetSoapException");
StreamWriter stream = new
StreamWriter(req.GetRequestStream(), UTF32Encoding.UTF8);
stream.Write(strSoapMessage.ToString());
stream.Flush();
stream.Close(); //releases (sets free) the request object
try
{
WebResponse response = req.GetResponse();
Stream str = response.GetResponseStream();
StreamReader rdr = new StreamReader(str);
Response.Write(rdr.ReadToEnd()); Response.End();
}
catch (WebException webEx)
{
Stream str = webEx.Response.GetResponseStream();
StreamReader rdr = new StreamReader(str);
Response.Write(rdr.ReadToEnd());
Response.End();
}
DEBUGGING TIPS
1) Break on all Exceptions (even if it is handled) Go to Debug > Exception
(Ctrl Alt E). This will be useful when you are given an unknown
application that collects all the errors and shows it at once on the top of
the screen. You do not know the source the error (or the exception). Just
enable this option and find out directly.
2) A faster way of debugging an error is to do it backwards i.e. go the known
bottommost function and start doing a step out (Shift – F11) to climb up and
see where it fails. This is better than debugging from start (top) and doing next
-> next. The “starting from bottommost” technique will give all the call
flows at once in the CallStack window.
3) If you want to change value of any variable while debugging (during runtime),
use immediate window and just write VAR1=”abc” in the window.
Or hover over the variable , write the value there itself and press Enter.
4) Conditional BreakPoint in Loops: You can attach a breakpoint in a FOR ot
FOREACH loop and when it hits it, right-click on the breakpoint and you can
put a CONDITION say when p.FirstName=="Paul". So you dont have to
iterate through the whole collection one by one. There are other options as
well when you right click.
GENERAL VISUAL STUDIO TIPS/.NET TIPS
1) To make traditional properties (.NET 2.0) faster, just declare the private variable,
select it, right click and click Refactor and click Encapsulate.
2) Tools > options > keyboard > TestDriven.NET > Assign keyboard shortcut to VS
plugin….( or any plugins for that matter)
3) When you are returning a collection say IList. Make sure its readonly so that its
underlying elements are not changed by the actor. To do that use
listPerson.ToList<Person>().AsReadOnly.
1) Install CCNet in a separate server (VM machine). Make sure that machine has
SDK for .NET framework (MSBuild is required). To be on the safer side I installed
full VS2008 (as the installation has SDK)
ccnet.config
In here
a) use sourcecontrol type as “vault” if you are using the vault command line
utility (works for me). If you are using a downloadable vault plugin use
type=”vaultplugin” (did not work for me . There were issue with
NetReflector.dll as well)
<sourcecontrol type="vault" autoGetSource="true" applyLabel="true"
cleanCopy="true">
WINDSOR CASTLE
Windsor castle is one of the part of Castle Project Framework. It is used as IoC
container (Dependency Injection). It creates objects by picking up the required
dependencies. Other frameworks are StructureMap and Spring.NET (.NET
counterpart for Spring of Java world). More Info @
http://dotnetslackers.com/articles/designpatterns/InversionOfControlAndDependencyInj
ectionWithCastleWindsorContainerPart1.aspx
<extensions>
<behaviorExtensions>
<add name="ConsoleOutputBehavior"
type="WcfService123.ConsoleOutputBehaviorExtensionElement, WcfService123,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</behaviorExtensions>
</extensions>
<endpointBehaviors>
<behavior name="subhasisBehavior">
<ConsoleOutputBehavior />
</behavior>
</endpointBehaviors>
To check the working of the message inspector, attach a breakpoint in the starting of
AfterReceiveReply (or whatever) and check reply.ToString().
Here are the basic steps to create a project and check-in files. For more info refer
http://gitref.org/
7) Next step is to add an alias for the repository created in Step 1. That alias would be
used
in the Git Client for referring the repo. in the next steps.
8) Type "git remote add ddgrid git@github.com:subhasisrout/DrilldownGrid.git"
9) Here ddgrid is the alias
10) Type"git push ddgrid master" (here master is the branch. you will be asked the
passphrase.)