information evening leads to rail inspection
On Wednesday held the beams in human Barth, a brief information session about the upcoming waste transport. Some Barth came in the preheated Bible center and allowed themselves to inform the consultant about the impending Castor. Ben showed the chronological development of the interim storage and illuminated the Lubmin. He also told those present about the upcoming Castor and what there is in the containers thus all. Again and again the visitors were discussing various topics. So they wondered if most people really go against nuclear energy on the road and maybe not but rather to protest against the government. That was the visitors, but also care support you both concerns. The jets of people rejoiced when the Barth-considered if they are not alone should do something. In short plenary to deliberate and found the idea of "Walking on the line long" absolutely legitimate. A People also made by a preparatory meeting immediately for their store and also available on the day of the Castor transport will leave the Castor ticker running for all to see. Thus within a very short time, an information evening fertilized to mobilize and perhaps finally to a blockade attempt.
The visitors agreed to meet next Wednesday at 18.00 for the clock to the preparatory meeting in ceramic Werkhof Sundische in the street 10 in Barth. There, during the Castor transport to Greifswald and the Castor Ticker run and find his contact persons. And on the day of the X Barth will then try to come near her to the track. One evening, which is thus left its mark.
Thursday, February 3, 2011
Tuesday, February 1, 2011
Good Ideas For Female Masterbtion
Friday, January 21, 2011
Islamic Quotes With Card
ASP.NET and asynchronous communication
Today I had to add a delete function to an old ASP.NET WebForms website. It was missing because there are a lot of relational data. So the steps to delete a record are:
- Click delete button
- Proof of existing relational data
- Show the result to the customer (and ask what to do)
- Delete all or cancel the delete action
Because I'm used to work with ASP.NET MVC, I thought on jQuery to solve the problem. Async calls to an Action on a Controller class and showing the result in a modal popup are easy tasks to do in ASP.NET MVC. This because of the MVC architecture, specially the Routing Engine used in MVC.
But in this case, I had to deal with ASP.NET WebForms and no routing to a Controller class. So how to solve the problem? I saw four different ways to do it:
1) Build a WCF Service and call it with jQuery
2) Create a ashx handler and call it with jQuery
3) Set the [WebMethod] Attribute to a method in the aspx page and call it with jQuery
4) Use the ScriptManager, the [WebMethod] and [ScriptMethod] Attribute
The first option (1), building a WCF Service is to much work for this small task.
The secound option (2) is quite good. The only thing I don't like is, I have to deal with two files what makes maintainance harder. Let's take a look at this solution anyway.
The jQuery code to call the handler looks like:
$(document).ready(function () {
$("#deleteButton").click(function () {
$.ajax({
type: "POST",
url: "Handler1.ashx",
data: "{'siteId':'" + id + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
// What you like to do on success
},
fail: function (msg) {
// What you like to do on error
}
});
});
});
The Handler (ashx-File) can be added easily with Visual Studio. Just select the Generic Handler template. The code looks like:
public class Handler1 : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
// Check for relational data and generate the message
var message = "Generated message for the user";
context.Response.ContentType = "text/plain";
context.Response.Write(message);
}
...
}
The third option (3) is in this case my favorite. Simple and easy. The jQuery call is the same, just the URL changes to something like
...
url: "SiteName.aspx/IsDeletable",
...
where the parameter after the slash is the name of the method.
In the ASPX-File we have to add a static method and decorate it with the [WebMethod] attribute. That's it! The code looks like:
[WebMethod]
public static string IsDeletable(Guid siteId)
{
// Check for relational data and generate the message
var message = "Generated message for the user";
return message;
}
IMPORTANT: The method has to be static.
The last option is ASP.NET WebForms specific and uses the ScriptManager. In my opinion do we have a better solution with the jQuery version. Anyway, here is what you need:
Add a ScriptManager as follow:
... ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" ...
Add JavaScript code to make the call:
...
PageMethods.IsDeletable(id);
...
Notice that this is just the call. Get and handle the return value has to be added as well.
And on the method in our aspx-File we do need an additional attribute:
[System.Web.Script.Services.ScriptMethod()]
Now it's up to you to choose your right solution.
Today I had to add a delete function to an old ASP.NET WebForms website. It was missing because there are a lot of relational data. So the steps to delete a record are:
- Click delete button
- Proof of existing relational data
- Show the result to the customer (and ask what to do)
- Delete all or cancel the delete action
Because I'm used to work with ASP.NET MVC, I thought on jQuery to solve the problem. Async calls to an Action on a Controller class and showing the result in a modal popup are easy tasks to do in ASP.NET MVC. This because of the MVC architecture, specially the Routing Engine used in MVC.
But in this case, I had to deal with ASP.NET WebForms and no routing to a Controller class. So how to solve the problem? I saw four different ways to do it:
1) Build a WCF Service and call it with jQuery
2) Create a ashx handler and call it with jQuery
3) Set the [WebMethod] Attribute to a method in the aspx page and call it with jQuery
4) Use the ScriptManager, the [WebMethod] and [ScriptMethod] Attribute
The first option (1), building a WCF Service is to much work for this small task.
The secound option (2) is quite good. The only thing I don't like is, I have to deal with two files what makes maintainance harder. Let's take a look at this solution anyway.
The jQuery code to call the handler looks like:
$(document).ready(function () {
$("#deleteButton").click(function () {
$.ajax({
type: "POST",
url: "Handler1.ashx",
data: "{'siteId':'" + id + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
// What you like to do on success
},
fail: function (msg) {
// What you like to do on error
}
});
});
});
The Handler (ashx-File) can be added easily with Visual Studio. Just select the Generic Handler template. The code looks like:
public class Handler1 : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
// Check for relational data and generate the message
var message = "Generated message for the user";
context.Response.ContentType = "text/plain";
context.Response.Write(message);
}
...
}
The third option (3) is in this case my favorite. Simple and easy. The jQuery call is the same, just the URL changes to something like
...
url: "SiteName.aspx/IsDeletable",
...
where the parameter after the slash is the name of the method.
In the ASPX-File we have to add a static method and decorate it with the [WebMethod] attribute. That's it! The code looks like:
[WebMethod]
public static string IsDeletable(Guid siteId)
{
// Check for relational data and generate the message
var message = "Generated message for the user";
return message;
}
IMPORTANT: The method has to be static.
The last option is ASP.NET WebForms specific and uses the ScriptManager. In my opinion do we have a better solution with the jQuery version. Anyway, here is what you need:
Add a ScriptManager as follow:
... ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" ...
Add JavaScript code to make the call:
...
PageMethods.IsDeletable(id);
...
Notice that this is just the call. Get and handle the return value has to be added as well.
And on the method in our aspx-File we do need an additional attribute:
[System.Web.Script.Services.ScriptMethod()]
Now it's up to you to choose your right solution.
Subscribe to:
Posts (Atom)