posted by 네코냥이 2014. 2. 2. 22:07

http://msdn.microsoft.com/ko-kr/library/system.web.ui.webcontrols.button.commandargument(v=vs.110).aspx


그러하도다. 

스크립단에서 CommendArgument 값 수정불가.



Button.CommandArgument 속성 (System.Web.UI.pdf


posted by 네코냥이 2014. 1. 24. 10:38

var prm = Sys.WebForms.PageRequestManager.getInstance();

        prm.add_endRequest(function () {

            // 0.5초 지연

            //setTimeout(RefreshRow_DragEvent, 500);

            RefreshRow_DragEvent();

        });

'.NET > .NET' 카테고리의 다른 글

[ASP.NET] 캐싱 개념  (145) 2014.02.09
[.NET] OnCommand  (0) 2014.02.02
asp.net How to get the id of the button user clicked  (306) 2014.01.23
[ASP.NET] Life Cycle 문서링크  (0) 2014.01.06
Response.Redirect Vs Server.Transfer in ASP.Net  (0) 2013.12.30
posted by 네코냥이 2014. 1. 23. 14:05

I have a small problem. I am developing an online seat reservation system which allow users to click and select seats. I am using buttons for seats. I am writing a method for the button click event for all buttons. I need to know how to identify the id of the button, user clicked. thanks in advance.

share|edit|flag
add comment

When you use a button clicked event, the signature of the method that'll handle the event goes like this:

private void foo (object sender, EventArgs e)

sender in this case is the button that was clicked. Just cast it to Button again and there you have. Like this:

Button button = (Button)sender;
int buttonId = button.ID;

You an have all your buttons pointing their Click event to the same method like this.

share|edit|flag
1
 
Thanks. It worked –  LIH Jul 10 '13 at 15:02
add comment

The first parameter of your event handler (object source or sometimes object sender) is a reference to the button that was clicked. All you need to do is cast it and then you can retrieve the id value, e.g.:

void Button_Click(object sender, EventArgs e)
{
    Button button = sender as Button;
    if (button != null)
    {
       //get the id here
    }
}


posted by 네코냥이 2013. 12. 30. 09:59

원본

http://www.c-sharpcorner.com/UploadFile/0c1bb2/response-redirect-and-server-transfer-in-Asp-Net/

원본 페이지: 

Response.Redirect Vs Server.Transfer in ASP.pdf


Background
 
Server.Transfer and Response.Redirect both are used to navigate from one page to another page, but there are some differences between them depending on the pages that we want to navigate to.
 
So let us learn step-by-step.
  • Response.Redirect

The Response.Redirect object transfers the page permanently to the next page and ends the processing of the first page and the new page processing continues on the redirected page but also it sends a command back to the browser; because of this one extra unnecessary round trip happens.

Suitable Uses

The suitable uses are:

  • to redirect the page from the same as well as a different web server.
  • don't care about causing additional round trips to the server on each request.
  • do not need to preserve the Query String and Form Variables from the original request.
  • want our users to be able to see the new redirected URL, where the page is redirected.
  • want to bookmark the page.

 

  • Server.Transfer

 

Server.Transfer navigates the pages within the same application or within the same server, the page is still in memory that can read the values directly from page2 on page1, in other words by using server.Transfer the page is not redirected permanently.

Suitable Uses

The suitable uses are:

  • to transfer the current page request to another .aspx page on the same server.
  • to preserve server resources and avoid the unnecessary round trips to the server.
  • to  preserve the Query String and Form Variables.
  • don't need to show the real URL of where we redirected the request in the user's Web Browser.
  • don’t want to bookmark the pages.
To demonstrate this, let us create one web application as in the following:
  1. "Start" - "All Programs" - "Microsoft Visual Studio 2010".
  2. "File" - "New WebSite" - "C#" - "Empty Web Site" (to avoid adding a master page).
  3. Provide the Project name such as "ResponseVsServer" or another as you wish and specify the location.
  4. Then right-click on Solution Explorer then seelct "Add New Item" - "Default.aspx" page (two web pages).


posted by 네코냥이 2013. 12. 26. 09:49


원글 주소:


Application_Start.pdf



posted by 네코냥이 2013. 12. 24. 10:47


Server side includes are available across different platforms and a useful for including static content. You can use them in IIS but I they need to be enabled in IIS7.

<!-- #include file="Static/Menu.html" -->

Instructions to enable SSI in IIS7 are available at http://tech.mikeal.com/ 

For dynamic content, there is a built-in method of templating called MasterPages, this should be used instead.


======================================================================


A very quick and dirty way is to put the following in your aspx page:

<% Response.WriteFile("~/htmlfilename.htm")%>

======================================================================




posted by 네코냥이 2013. 11. 9. 22:25

I'm fairly new to ASP.NET MVC and am not sure how best to handle the following situation.

A method in my controller needs to load some data based on an ID argument. Under normal circumstances, this ID argument will be set to a valid ID of an entity within my database. I construct some data and place it in ViewBag, which the view uses to render the page.

However, I would like some basic error handling just in case the ID argument is not valid. Although I could write a bunch of error handling code in the view, it would be much simpler not to display the view if there is a major misuse or malfunction of the site.

Is there a way the controller could simply return a "Item not found" string or something like that, and display that rather than the normal view? Or perhaps someone can suggest a better idea?

======================================================================


if (itemId == null)
{
    return Content("Item not found");
}

Or if you want to return an HTTP 404 instead:

throw new HttpException(404, "Item Not Found");


posted by 네코냥이 2013. 11. 6. 10:26


static void HasRows(SqlConnection connection)

{

    using (connection)

    {

        SqlCommand command = new SqlCommand(

          "SELECT CategoryID, CategoryName FROM Categories;",

          connection);

        connection.Open();


        SqlDataReader reader = command.ExecuteReader();


        if (reader.HasRows)

        {

            while (reader.Read())

            {

                Console.WriteLine("{0}\t{1}", reader.GetInt32(0),

                    reader.GetString(1));

            }

        }

        else

        {

            Console.WriteLine("No rows found.");

        }

        reader.Close();

    }

}


posted by 네코냥이 2013. 9. 13. 09:39


Various Ways to Pass Data Among Web Forms.pdf