1. TextBox Enter key 이벤트 입히기

    TextBox1.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('"+Button1.UniqueID+"').click();return false;}} else {return true}; ");

 

  1. TexBox 이벤트 넘기기

     

    function clickButton(e, buttonid){

          var evt = e ? e : window.event;

          var bt = document.getElementById(buttonid);

          if (bt){

              if (evt.keyCode == 13){

                    bt.click();

                    return false;

              }

          }

    }

    //code behind
    TextBox1.Attributes.Add("onkeypress", "return clickButton(event,'" + Button1.ClientID + "')");

    <input name="TextBox1" type="text" id="TextBox1" onkeypress="return clickButton(event,'Button1')"  />

Posted by I will catch this man. 울트라고스톱
1. 신규데이타
- sp_InsertWork_Mailbox 를 이용
- 이미 사용자는 라이브아이디가 존재 해야 한다.
2. 트리그룹설정
- 버튼클릭시 관계설정하는 순서
- tbl_Mailbox에서 grouping 값이 'N' 값만 찾느다.
- Ca1 ~ Ca5 까지의 code값에 해당하는 seq값을 tbl_Objects에서 찾는다. : parentseq
- tbl_mailbox의 objectseq를 찾는다. : childseq
- 각각 찾아서 sp_insertwork_newrelation 을 실행한다.

저작자 표시
Posted by I will catch this man. 울트라고스톱

create table tbl_CATree(

    ca_No int primary key,

    ca_AttributeName nvarchar(100),

    ca_DisplayName nvarchar(100),

    ca_PNo int )

 

insert into tbl_CATree(ca_No,ca_AttributeName,ca_DisplayName,ca_PNo) values( 1,'chosunUniversity','조선대학교',0);

insert into tbl_CATree(ca_No,ca_AttributeName,ca_DisplayName,ca_PNo) values( 2,'a','인문과학대학',1);

insert into tbl_CATree(ca_No,ca_AttributeName,ca_DisplayName,ca_PNo) values( 3,'b','자연과학대학',1);

insert into tbl_CATree(ca_No,ca_AttributeName,ca_DisplayName,ca_PNo) values( 4,'c','법과대학',1);

insert into tbl_CATree(ca_No,ca_AttributeName,ca_DisplayName,ca_PNo) values( 5,'d','사회과학대학',1);

insert into tbl_CATree(ca_No,ca_AttributeName,ca_DisplayName,ca_PNo) values( 6,'e','경상대학',1);

insert into tbl_CATree(ca_No,ca_AttributeName,ca_DisplayName,ca_PNo) values( 7,'f','공과대학',1);

insert into tbl_CATree(ca_No,ca_AttributeName,ca_DisplayName,ca_PNo) values( 8,'g','전자정보공과대학',1);

insert into tbl_CATree(ca_No,ca_AttributeName,ca_DisplayName,ca_PNo) values( 9,'h','사범대학',1);

insert into tbl_CATree(ca_No,ca_AttributeName,ca_DisplayName,ca_PNo) values( 10,'i','외국어대학',1);

insert into tbl_CATree(ca_No,ca_AttributeName,ca_DisplayName,ca_PNo) values( 11,'j','체육대학',1);

insert into tbl_CATree(ca_No,ca_AttributeName,ca_DisplayName,ca_PNo) values( 12,'k','의과대학',1);

 

insert into tbl_CATree(ca_No,ca_AttributeName,ca_DisplayName,ca_PNo) values( 13,'l','국어국문학과',2);

insert into tbl_CATree(ca_No,ca_AttributeName,ca_DisplayName,ca_PNo) values( 14,'m','영어영문학과',2);

insert into tbl_CATree(ca_No,ca_AttributeName,ca_DisplayName,ca_PNo) values( 15,'n','사학과',2);

insert into tbl_CATree(ca_No,ca_AttributeName,ca_DisplayName,ca_PNo) values( 16,'o','철학과',2);

 

insert into tbl_CATree(ca_No,ca_AttributeName,ca_DisplayName,ca_PNo) values( 17,'p','수학과',3);

insert into tbl_CATree(ca_No,ca_AttributeName,ca_DisplayName,ca_PNo) values( 18,'q','생물학과',3);

 

insert into tbl_CATree(ca_No,ca_AttributeName,ca_DisplayName,ca_PNo) values( 19,'r','법학과',4);

insert into tbl_CATree(ca_No,ca_AttributeName,ca_DisplayName,ca_PNo) values( 20,'s','글로벌법학과',4);

 

insert into tbl_CATree(ca_No,ca_AttributeName,ca_DisplayName,ca_PNo) values( 21,'t','정치외교학부',5);

insert into tbl_CATree(ca_No,ca_AttributeName,ca_DisplayName,ca_PNo) values( 22,'u','행정.복지학부',5);

 

select * from tbl_CATree

위내용은 실제 구현된 부분이다.

create procedure sp_deptListForTree

as

begin

if exists (select top 10 * from tempdb.sys.objects where name like '#TempDept%') drop table #TempDept

create table #TempDept ( ca_No int, ca_AttributeName varchar(100), ca_DisplayName varchar(100), ca_PNo int,lvl int )

declare @lvl int

set @lvl = 1

insert into #TempDept

        select top 1 ca_No, ca_AttributeName, ca_DisplayName,ca_PNo, @lvl from tbl_CATree

        where ca_No=1 -- 루트의ca_No를지정해준다.

while @@rowcount > 0

begin

        set @lvl = @lvl + 1

        insert into #TempDept

            select a.ca_No, a.ca_AttributeName, a.ca_DisplayName,a.ca_PNo, @lvl

            from tbl_CATree as a join #TempDept

                as b on a.ca_PNo = b.ca_No and b.lvl = @lvl-1

    end

select * from #TempDept order by lvl, ca_AttributeName asc

end

 

/// <summary>

/// 노드 만들기

/// </summary>

private void RenderNodes()

{

//TreeNodeList tnList = new TreeNodeList();

//TreeNodeList.Tnode tnode=tnList.MakeNode(tnList.GetDataSet());

//Coolite.Ext.Web.TreeNode root = null;

//root = new Coolite.Ext.Web.TreeNode(tnode.ca_DisplayName);

//root.Expanded = true;

//root.NodeID = tnode.ca_DisplayName;

//this.TreePanel1.Root.Add(root);

 

//foreach (var v1 in tnode.TnodeList)

//{

// Coolite.Ext.Web.TreeNode parentNode = new Coolite.Ext.Web.TreeNode(v1.ca_DisplayName);

// parentNode.NodeID = v1.ca_DisplayName;

// parentNode.Expanded = false;

// root.Nodes.Add(parentNode);

 

// foreach (var v2 in v1.TnodeList)

// {

// Coolite.Ext.Web.TreeNode childNode = new Coolite.Ext.Web.TreeNode(v2.ca_DisplayName,Icon.FolderUser);

// childNode.NodeID = v2.ca_DisplayName;

// childNode.Expanded = false;

// parentNode.Nodes.Add(childNode);

// }

//}

string oldPid = "old";

Hashtable hstDept = new Hashtable();

Coolite.Ext.Web.TreeNode pnode = new Coolite.Ext.Web.TreeNode();

//ManagementTool.App_Code.BzLogic.Nodes.TreeDB tdb = new TreeDB();

TreeNodeList tList = new TreeNodeList();

List<TreeNodeList.Tnode> tnodeList = tList.MakeNode();

 

foreach (TreeNodeList.Tnode tnode in tnodeList)

{

Coolite.Ext.Web.TreeNode node = new Coolite.Ext.Web.TreeNode(tnode.ca_DisplayName);

node.NodeID = tnode.ca_DisplayName;

node.Expanded = false; ;

 

hstDept.Add(tnode.ca_No, node);

// method 1

if (!tnode.ca_Pno.ToString().Equals(oldPid))

{

pnode = (Coolite.Ext.Web.TreeNode)hstDept[tnode.ca_Pno];

if (tnode.ca_No == tnodeList.First().ca_No)

{

node.Expanded = true;

TreePanel1.Root.Add(node);

 

}else{

AddChild( pnode, node );

}

oldPid = tnode.ca_Pno.ToString();

}

else{

AddChild( pnode, node );

}

/* method 2 if( ddata.id == "0" ){ tview.Nodes.Add( node ); }else{ AddChild( (TreeNode)hstDept[ ddata.pid ], node ); } */

}// foreach

 

}

 

// Add Chile Node

private void AddChild(

Coolite.Ext.Web.TreeNode pNode,

Coolite.Ext.Web.TreeNode cNode)

{

pNode.Nodes.Add( cNode );}

 

// Generate Node

private Coolite.Ext.Web.TreeNode GetNode(string NodeName, int ID,bool Expand)

{

Coolite.Ext.Web.TreeNode tnode = new Coolite.Ext.Web.TreeNode();

tnode.Text = NodeName;

tnode.Expanded = Expand;

tnode.NodeID = ID.ToString();

return tnode;

}

 

Posted by I will catch this man. 울트라고스톱

 

트리를 통한 조직도 구성하기

create table t_dept ( id int null, dname varchar( 50 ), pid int)

 

insert into t_dept( id, dname, pid ) values ( 0, '테스트회사', null )

insert into t_dept( id, dname, pid ) values ( 1, '1단계부서', 0 )

insert into t_dept( id, dname, pid ) values ( 2, '1단계부서', 0 )

insert into t_dept( id, dname, pid ) values ( 3, '2단계부서', 1 )

insert into t_dept( id, dname, pid ) values ( 4, '2단계부서', 1 )

insert into t_dept( id, dname, pid ) values ( 5, '2단계부서', 2 )

insert into t_dept( id, dname, pid ) values ( 6, '3단계부서', 4 )

insert into t_dept( id, dname, pid ) values ( 7, '3단계부서', 4 )

insert into t_dept( id, dname, pid ) values ( 8, '3단계부서', 7 )

insert into t_dept( id, dname, pid ) values ( 9, '3단계부서', 7 )

 

select * from t_dept;

 

다음은 출력화면입니다.

위 그림은 전형적인 조직도의 모습입니다.

Pid는 부모id를 나타냅니다.

다음의 프로시저는 이 테이블에서 깊이도(depth)를 구하는 내용입니다.

이걸 이용해서 계층적인트리를 구성할수 있습니다.

 

다음은 프로시저의 내용입니다.

create procedure sp_deptList

as

begin

if exists (select top 10 * from tempdb.sys.objects where name like '#TempDept%') drop table #TempDept

create table #TempDept ( id varchar(50), name varchar(100), pid varchar(50), lvl tinyint )

declare @lvl tinyint

set @lvl = 1

insert into #TempDept select top 1 id, dname, pid, @lvl from t_dept

where id = 0

while @@rowcount > 0

begin

        set @lvl = @lvl + 1

        insert into #TempDept

            select a.id, a.dname, a.pid, @lvl

            from t_dept as a join #TempDept

                as b on a.pid = b.id and b.lvl = @lvl-1

    end

select * from #TempDept order by lvl, name asc

end

 

exec sp_deptlist

 

다음은 프로시저을 실행 화면 입니다.

 

다음은 이 구조를 클래스화 하는 내용입니다.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Data.SqlClient;

using System.Data;

using System.Configuration;

namespace ManagementTool.App_Code.BzLogic.Nodes

{

public class TreeDB

{

 

public List<DeptData> GetDeptList()

{

List<DeptData> arrDept = new List<DeptData>();

string connectionString = ConfigurationManager.ConnectionStrings["TreeDB"].ConnectionString;

SqlConnection sqlConn = new SqlConnection(connectionString);

string strSql = "sp_deptList";

SqlCommand sqlCmd = new SqlCommand(strSql, sqlConn);

sqlCmd.CommandType = CommandType.StoredProcedure;

sqlConn.Open();

SqlDataReader myReader = sqlCmd.ExecuteReader();

while (myReader.Read())

{

DeptData ddata = new DeptData();

ddata.id = myReader["id"].ToString();

ddata.name = myReader["Name"].ToString();

ddata.pid = myReader["pid"].ToString();

arrDept.Add(ddata);

}

myReader.Close();

sqlConn.Close();

return arrDept;

}

public class DeptData

{

public string id; public string name; public string pid;

}

}

}

 

다음은 최종적이로 트리를 구현하는 부분 입니다.

string oldPid = "old";

Hashtable hstDept = new Hashtable();

Coolite.Ext.Web.TreeNode pnode = new Coolite.Ext.Web.TreeNode();

ManagementTool.App_Code.BzLogic.Nodes.TreeDB tdb = new TreeDB();

List<TreeDB.DeptData> arrDept = tdb.GetDeptList();

 

foreach (TreeDB.DeptData ddata in arrDept)

{

Coolite.Ext.Web.TreeNode node = GetNode(ddata.name, ddata.id, true, "", "", "");

hstDept.Add( ddata.id, node );

// method 1

if( ddata.pid != oldPid ){

pnode = (Coolite.Ext.Web.TreeNode)hstDept[ddata.pid];

if( ddata.id == "0" )

{

TreePanel1.Root.Add(node);

}else{

AddChild( pnode, node );

}

oldPid = ddata.pid;

}else{

AddChild( pnode, node );

}

 

private void AddChild(

Coolite.Ext.Web.TreeNode pNode,

Coolite.Ext.Web.TreeNode cNode)

{

pNode.Nodes.Add( cNode );}

 

// Generate Node

private Coolite.Ext.Web.TreeNode GetNode(

string NodeName,

string ID,

bool Expand,

string ImgUrl,

string sTarget,

string sUrl

)

{

Coolite.Ext.Web.TreeNode tnode = new Coolite.Ext.Web.TreeNode();

tnode.Text = NodeName;

tnode.Expanded = Expand;

tnode.NodeID= ID;

return tnode;

}

 

최종적으로 구현된 트리

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

그룹관리 툴 업무기능정의  (0) 2009/11/29
Tree 조직도 구성하기2  (0) 2009/11/17
트리를 통한 조직도 구성하기  (0) 2009/11/17
Coolite confirm 과 delegate  (0) 2009/11/12
[AjaxMethod] and UserControls  (0) 2009/11/12
AjaxMethod의 IDMODE  (0) 2009/11/12
Posted by I will catch this man. 울트라고스톱

   

Coolite에서 confirm 창을 이용하는 방법중에 하나입니다.

Yes나 no의 버튼 값에 따라 다르게 로직을 돌리고 싶을 때 유용합니다.

Ext.Msg.confirm('확인',msg,continueAjaxEvent.createDelegate(button,[button,e],true),button);

여기에서 continueAjaxEvent.createDelegate(button,[button,e],true) 이부분이 델리게이트이며

밑에 continueAjaxEvent 가 함수 입니다.

다음은 제가 작성했던 코드 입니다.

<ext:MenuItem ID="MenuItem3" runat="server" Text="선택한 계정들 삭제하기" Icon="Delete" >

<AjaxEvents>

<Click OnEvent="DeleteRows">

<ExtraParams>

<ext:Parameter Name="CheckedValues" Value="Ext.encode(#{MainGridPanel}.getRowsValues())" Mode="Raw"></ext:Parameter>

</ExtraParams>

</Click>

</AjaxEvents>

<Listeners>

<Click Handler="function(button,e){

if( #{MainGridPanel}.hasSelection()==false ){

Ext.Msg.alert('선택오류','아무것도 선택하지 않았습니다.');

return false;

}else

{

var msg=''+#{MainGridPanel}.selModel.getCount()+'건을 삭제 하시겠습니까?';

Ext.Msg.confirm('확인',msg,continueAjaxEvent.createDelegate(button,[button,e],true),button);

return false;

}

function continueAjaxEvent(btnID,text,btnCFG,sender,e){

if(btnID=='yes' )

{

sender.ajaxEvents.click.fn.apply(sender,[sender,e]);

}

}

}" />

</Listeners>

</ext:MenuItem>

   

다음 그림은 실행 화면 입니다.

아래의 빨간색 부분이 confirm화면입니다.

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

Tree 조직도 구성하기2  (0) 2009/11/17
트리를 통한 조직도 구성하기  (0) 2009/11/17
Coolite confirm 과 delegate  (0) 2009/11/12
[AjaxMethod] and UserControls  (0) 2009/11/12
AjaxMethod의 IDMODE  (0) 2009/11/12
AjaxMethod Overview  (3) 2009/11/12
Posted by I will catch this man. 울트라고스톱

The AjaxMethodNamespace property has been set to "CompanyX" on the

<ext:ScriptManager> which overrides the default [AjaxMethod] Namespace value of "Coolite.AjaxMethods".

Coolite.AjaxMethods의 네임 스페이스를 CompanyX로 설정했다는 말이다.

UserControl with [AjaxMethod]

An [AjaxMethod] can be defined within a UserControl(.ascx) and called from within the UserControl or from the Parent Page.

  • AjaxMethod 어트리부트는 유저컨트롤 에서 정의 될수 있고, 유저컨트롤이나 부모페이지에서 호출될수 있다.

The following sample demonstrates adding a UserControl to the Page and setting a custom Name

property for each. The UserControl defines an [AjaxMethod] which is called when the Button is clicked.

  • 다음은 페이지에 유저컨트롤을 추가 하는것과 커스텀네임을 설정하는 것을 보여준다.

Code

<uc:MyUserControl ID="UserControl1" runat="server" Name="Bob" />

<uc:MyUserControl ID="UserControl2" runat="server" Name="Billy" />

       

Code (.ascx)

<%@ Control Language="C#" %>

<%@ Register assembly="Coolite.Ext.Web" namespace="Coolite.Ext.Web" tagprefix="ext" %>

<script runat="server">

protected void Page_Load(object sender, EventArgs e)

{

if (!Ext.IsAjaxRequest)

{

this.Button1.Text = string.Concat("UserControl (", this.Name, ")");

}

}

       

[AjaxMethod]

public void GetName()

{

Ext.Msg.Alert("Name", this.Name).Show();

}

       

public string Name { get; set; }

</script>   

<ext:Button ID="Button1" runat="server">

<Listeners>

<Click Handler="#{AjaxMethods}.GetName();" />

</Listeners>

</ext:Button>

       

Calling UserControl [AjaxMethod] from Parent .aspx Page

  • Parent.aspx 에서 유저컨트롤의 AjaxMethod 호출하기

The following sample demonstrates manually calling the [AjaxMethod] defined in the above UserControls from the parent Page.

  • 다음은 부모페이지에서 위의 유저컨트롤에 정의된 AjaxMethod를 호출하는 것을 보여준다.

Code

<ext:Button ID="Button1" runat="server" Text="Call UserControl AjaxMethod (Bob)">

<Listeners>

<Click Handler="CompanyX.UserControl1.GetName();" />

</Listeners>

</ext:Button>

       

<ext:Button ID="Button2" runat="server" Text="Call UserControl AjaxMethod (Billy)">

<Listeners>

<Click Handler="CompanyX.UserControl2.GetName();" />

</Listeners>

</ext:Button>

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

트리를 통한 조직도 구성하기  (0) 2009/11/17
Coolite confirm 과 delegate  (0) 2009/11/12
[AjaxMethod] and UserControls  (0) 2009/11/12
AjaxMethod의 IDMODE  (0) 2009/11/12
AjaxMethod Overview  (3) 2009/11/12
Fire Off Coolite Button from Javascript  (0) 2009/11/12
Posted by I will catch this man. 울트라고스톱

   

유저컨트롤릐 AjaxMethod 호출 하기 입니다.

<%@ Page Title="" Language="C#" MasterPageFile="NoneID.Master" %>

<%@ Register assembly="Coolite.Ext.Web" namespace="Coolite.Ext.Web" tagprefix="ext" %>

<%@ Register src="Alias.ascx" tagname="Alias" tagprefix="uc1" %>

   

<asp:Content ID="Content1" ContentPlaceHolderID="Body" runat="server">

<h3>Example</h3>

<uc1:Alias ID="Alias1" runat="server" />

<ext:Button ID="Button1" runat="server" Text="UserControl">

<Listeners>

<Click Handler="Coolite.AjaxMethods.UC.HelloUserControl();" />

</Listeners>

</ext:Button>

<br />

<ext:Button ID="Button2" runat="server" Text="MasterPage">

<Listeners>

<Click Handler="Coolite.AjaxMethods.HelloMasterPage();" />

</Listeners>

</ext:Button>

</asp:Content>

위의 굵은 글시로 밑줄 그은 부분이 유저컨트롤의 호출 부분입니다.

유저컨트롤의 어트리뷰트 설정은 다음과 같습니다.

using Coolite.Ext.Web;

[AjaxMethodProxyID(IDMode = AjaxMethodProxyIDMode.Alias, Alias = "UC")]

public partial class AliasID : System.Web.UI.UserControl

{

[AjaxMethod]

public void HelloUserControl()

{

Ext.Msg.Alert("Message", "Hello from UserControl").Show();

}

}

위처럼 하면 된다.

   

Coolite.AjaxMethods.UC.HelloUserControl();" 이렇게 호출하기

[AjaxMethodProxyID(IDMode = AjaxMethodProxyIDMode.Alias, Alias = "UC")] : 어트리뷰트 설정하기

   

다음 부분의 마스터페이지의 AjaxMethod 호출 하기 입니다.

using Coolite.Ext.Web;

[AjaxMethodProxyID(IDMode = AjaxMethodProxyIDMode.None)]

public partial class NoneID : System.Web.UI.MasterPage

{

[AjaxMethod]

public void HelloMasterPage()

{

Ext.Msg.Alert("Message", "Hello from MasterPage").Show();

}

}

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

Coolite confirm 과 delegate  (0) 2009/11/12
[AjaxMethod] and UserControls  (0) 2009/11/12
AjaxMethod의 IDMODE  (0) 2009/11/12
AjaxMethod Overview  (3) 2009/11/12
Fire Off Coolite Button from Javascript  (0) 2009/11/12
TreePanel and NodeLoad  (0) 2009/11/11
Posted by I will catch this man. 울트라고스톱

 

아작스 메소드의 사용방법: 대충 다음과 같다. 영어지만 해석에는 큰 무리가 없다.

순수 extjs를 사용하는것보다 asp.net을 이용하면 손쉽게 작성할수 있다.

원문: http://examples.coolite.com/Examples/Events/AjaxMethods/Overview/

위 주소의 내용을 그냥 카피앤페이스트 했다.

 

An AjaxMethod provides the ability to call server-side .NET Methods from client-side JavaScript code.

Decorating a server-side public or public static Method with the [AjaxMethod] Attribute will expose

the server-side Method to your client-side JavaScript.

 

Syntax Example

[AjaxMethod]

public void SetTimeStamp(string text)

{

this.Label1.Text = DateTime.Now.ToLongTimeString();

}

1. Basic AjaxMethod

The following demonstrates a simple [AjaxMethod] which updates an <ext:Label> control.

 

Code

<script runat="server">

[AjaxMethod]

public void SetTimeStamp()

{

this.Label1.Text = string.Concat("Server Time: ", DateTime.Now.ToLongTimeString());

}

</script>

<ext:Button ID="Button5" runat="server" Text="Click Me" Icon="Lightning">

<Listeners>

<Click Handler="Coolite.AjaxMethods.SetTimeStamp();" />

</Listeners>

</ext:Button>

 

2. Return a string from an AjaxMethod

Any type object can be returned from an AjaxMethod.

The object is serialized into JSON. The serialized object is sent as the 'result' parameter to the 'success' function

as configured in the AjaxMethod configuration.

Code

<script runat="server">

[AjaxMethod]

public string GetTimeStamp()

{

return DateTime.Now.ToLongTimeString();

}

</script>

 

<ext:Button ID="Button1" runat="server" Text="Click Me" Icon="Lightning">

<Listeners>

<Click Handler="

Coolite.AjaxMethods.GetTimeStamp({

success: function(result) {

Ext.Msg.alert('Server Time', result);

}

});" />

</Listeners>

</ext:Button>

 

3. Pass multiple arguments to an AjaxMethod

If the server-side AjaxMethod requires parameters, the client-side AjaxMethod will also be created

and expect to be passed values for the two arguments.

For example, if the server-side Method requires a string and int argument,

both a valid string and number must be passed to the client-side function.

 

Example

Company InformationCompany Name:

Code

<script runat="server">

[AjaxMethod]

public void LogCompanyInfo(string name, int count)

{

string template = string.Concat("{0} has approximately {1} employees.");

string[] employees = new string[4] { "1-5", "6-25", "26-100", "100+" };

 

this.Label3.Text = string.Format(template, name, employees[count]);

}

</script>

 

<ext:Button ID="Button1" runat="server" Text="Submit">

<Listeners>

<Click Handler="Coolite.AjaxMethods.LogCompanyInfo('Coolite Inc.', 0);" />

</Listeners>

</ext:Button>

 

4. Calling static Method AjaxMethod and return a string (Super Fast + Best Performance)

When calling a public server-side Method, but default the complete Page lifecycle is executed and the

Method has access to all web controls on the Page.

With a 'static' [AjaxMethod] the Page lifecycle is not executed and access to the Page WebControls are not possible.

This reduces the processing overhead and optimizes performance.

Code

<script runat="server">

[AjaxMethod]

public static string GetTimeStamp4()

{

return DateTime.Now.ToLongTimeString();

}

</script>

 

<ext:Button xrunat="server" Text="Click Me" Icon="Lightning">

<Listeners>

<Click Handler="

Coolite.AjaxMethods.GetTimeStamp4({

success: function(result) {

Ext.Msg.alert('Server Time', result);

}

});" />

</Listeners>

</ext:Button>

 

5. Return a Customer object from a static AjaxMethod

Any type of object can be returned from a AjaxMethod.

The following example creates and returns a 'Customer' object.

The Customer object is serialized into JSON and returned to the client (browser).

Within the AjaxMethod configuration object, the 'result' parameter is the return object.

 

Code

<script runat="server">

// Define Customer Class

public class Customer

{

public int ID { get; set; }

public string FirstName { get; set; }

public string LastName { get; set; }

public string Company { get; set; }

public Country Country { get; set; }

public bool Premium { get; set; }

}

 

// Define Country Class

public class Country

{

public Country(string name)

{

this.Name = name;

}

 

public string Name { get; set; }

}

 

[AjaxMethod]

public static Customer GetCustomer()

{

// Get your Customer data from somewhere...

 

return new Customer() {

ID = 99,

FirstName = "Geoffrey",

LastName = "McGill",

Company = "Coolite Inc.",

Premium = true,

Country = new Country("Canada")

};

}

</script>

 

<ext:Button ID="Button1" runat="server" Text="Click Me" Icon="Lightning">

<Listeners>

<Click Handler="

Coolite.AjaxMethods.GetCustomer({

success: function(customer) {

var template = 'ID: {0}{6} Name: {1} {2}{6} Company: {3}{6} Country: {4}{6} Premium Member: {5}',

msg = String.format(template,

customer.ID,

customer.FirstName,

customer.LastName,

customer.Company,

customer.Country.Name,

customer.Premium,

'<br /><br />');

 

Ext.Msg.alert('Customer', msg);

}

});" />

</Listeners>

</ext:Button>

 

6. Disable the AjaxMethod ClientProxy Creation

When the [AjaxMethod] Attribute is added to a server-side Method, by default, a JavaScript function of the same name,

and accepting the same parameters will be created in the client-side Coolite.AjaxMethods arry.

For example, if we create a server-side Method called "GetTimeStamp", on the client,

the Coolite.AjaxMethods.GetTimeStamp JavaScript function will also be created.

 

There may be scenarios where developers may decide to create an AjaxMethod, but not expose the corresponding

JavaScript function on the client. You can configure the AjaxMethod to ignore creating the corresponding client-side

JavaScript function by setting the ClientProxy.Ignore property on that particular AjaxMethod.

 

Code

[AjaxMethod(ClientProxy = ClientProxy.Ignore)]

public string GetTimeStamp()

{

return DateTime.Now.ToLongTimeString();

}

 

If the AjaxMethod is set with ClientProxy.Ignore, the corresponding client-side proxy function will not be created,

but the AjaxMethod can still be called. The AjaxMethod proxy functions are conveinience wrappers around the underlying

Coolite.AjaxMethod.request() function.

 

Any server-side AjaxMethod can be called directly (without a client-side proxy function), by configuring the

Coolite.AjaxMethod.request() function.

 

request ( string methodName , [Object options] ) : void

Calls the server-side [AjaxMethod] as specified in the methodName parameter.

Parameters:

methodName : String

The server-side Method name to call.

options : Object

(optional) An object containing configuration properties. This options object may contain any of the following properties,

or options as defined in Ext.Ajax.request.

success : Function

The JavaScript function to invoke on successful response from the AjaxMethod.

The "result" parameter is passed to the success function.

failure : Function

The JavaScript function to invoke if a failure response is returned from the AjaxMethod.

The "errorMessage" parameter is passed to the success function.

specifier : String

The server-side Method access specifier, options inlcude ("public", "static").

The specifier of "public" is the default value and does not need to be explicitly set.

If the server-side Method is a static Method, the specifier options must be set to "static".

method : String

The type of http request to make, options include ("POST", "GET").

The method of "POST" is the default value.

url : String

A custom url to call the AjaxMethod from. The AjaxMethod does not need to be configured on the "Parent Page".

If no url is provided, the request options will use the <form>'s action attribute. If the action attribute is empty,

the request options will use the window.location.href value. If the window.location.href value ends with a forward-slash ("/"),

the IIS web server may not be able to process the "POST" request. Under this scenario, you must set the "method" options property to "GET".

control : String

The ID of the UserControl which contains the AjaxMethod. An AjaxMethod can be configured within a .ascx file and called from a Parent .aspx Page.

timeout : Number

The timeout in milliseconds to be used for requests. (defaults to 30000)

eventMask : Object

(optional) An EventMask options object. This options object may contain any of the following properties:

showMask : Boolean

true to show mask (defaults to false).

msg : String

The text to display in a centered loading message box (defaults to 'Working...').

msgCls : String

The CSS class to apply to the loading message element (defaults to "x-mask-loading")

target : String

The target element to apply the mask to, options include ("page", "customtarget").

If "customtarget", the customTarget configuration option should be set.

customTarget : String

The id of the target element, or a instance of the target element.

minDelay : Number

The minimum amount of time to display the mask (defaults to 0).

Setting the minDelay provides and minimum amount of time to display a message

to the user before removing mask and executing success, failure and/or callback functions.

Returns:

•void

Code

<script runat="server">

[AjaxMethod(ClientProxy = ClientProxy.Ignore)]

public string GetTimeStamp6()

{

return DateTime.Now.ToLongTimeString();

}

</script>

 

<ext:Button ID="Button1" runat="server" Text="Click Me" Icon="Lightning">

<Listeners>

<Click Handler="Coolite.AjaxMethod.request(

'GetTimeStamp3', {

success: function(result) {

Ext.Msg.alert('Message', result);

}

});" />

</Listeners>

</ext:Button>

 

7. Pass AjaxMethod configuration object to proxy function

An AjaxMethod configuration object can always be passed as the last parameter on any AjaxMethod proxy function.

Code

<script runat="server">

[AjaxMethod]

public string LogMessage(string msg)

{

// Log the message somewhere...

return msg;

}

</script>

 

<ext:Button ID="Button4" runat="server" Text="Click Me" Icon="Lightning">

<Listeners>

<Click Handler="Coolite.AjaxMethods.LogMessage('Hello World', {

success: function(result) {

Ext.Msg.alert('Message', result);

},

eventMask: {

showMask: true,

minDelay: 500

}

});" />

</Listeners>

</ext:Button>

  

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

[AjaxMethod] and UserControls  (0) 2009/11/12
AjaxMethod의 IDMODE  (0) 2009/11/12
AjaxMethod Overview  (3) 2009/11/12
Fire Off Coolite Button from Javascript  (0) 2009/11/12
TreePanel and NodeLoad  (0) 2009/11/11
Open window from usercontrol  (0) 2009/11/11
Posted by I will catch this man. 울트라고스톱

This one could be easy. I have a button statically named on my main grid.

I want to be able to invoke its Handlers and Fn's from other windows.

Using Firefox and Firebug I can confirm that I can get the Button but I don't know the javascript to fire ti off. Any help? Thanks.

function RefreshTimesheet() {

var btn = document.getElementById('btnRefresh_TimeCardGrid');

console.log(dumper(btn));

if (btn != undefined) {

btn.click();

}

}

   

위 질문에 대한 Reply 들

  • All Coolite controls can be referenced by ClientID. If Controls doesn't placed to the NamingContainer (master page, user control) then ID=ClientID. Also you can set IDMode=Static for generate ClientID as ID. To fire click you need execute the following js code

    Button1.fireEvent('click');

  • Hi, You don't need to use document.getElementById. It gives pure dom element

    Just use ClientID directly. All Coolite controls define own variable which eqaul own ClientID. So, just try

    btnRefresh_TimeCardGrid.fireEvent('click');

    or

    Ext.getCmp('btnRefresh_TimeCardGrid').fireEvent('click');

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

AjaxMethod의 IDMODE  (0) 2009/11/12
AjaxMethod Overview  (3) 2009/11/12
Fire Off Coolite Button from Javascript  (0) 2009/11/12
TreePanel and NodeLoad  (0) 2009/11/11
Open window from usercontrol  (0) 2009/11/11
How to invoke click of a button clientside?  (0) 2009/11/11
Posted by I will catch this man. 울트라고스톱

Hello again.

Trying to determine the Checkbox state of a node during the NodeLoad ajax call.  When I make the NodeLoad call the NodeLoadEventArgs contains the NodeId of the node that made the call.

However, I need to determine this nodes Checkbox state during NodeLoad.  So that I can set any children with the same Checkbox state.

How do I get the Node Checkbox state (or even the node itself) that caused the NodeLoad?  I don't see any FindNode or GetNode option available.

Thanks.

à


Do you use PageTreeLoader?

If yes then use BaseParams of loader

<ext:Parameter Name="checked" Value="node.attributes.checked" Mode="Raw" />

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

AjaxMethod Overview  (3) 2009/11/12
Fire Off Coolite Button from Javascript  (0) 2009/11/12
TreePanel and NodeLoad  (0) 2009/11/11
Open window from usercontrol  (0) 2009/11/11
How to invoke click of a button clientside?  (0) 2009/11/11
Coolite 에서 ajax와 listener 이용  (0) 2009/11/10
Posted by I will catch this man. 울트라고스톱

BLOG main image
by 울트라고스톱

공지사항

카테고리

전체보기 (145)
mY Story (1)
C# winform (34)
ASP.NET (66)
생활 (12)
영어 (0)
북마크 (0)
Computer (6)
Programming (1)
Database (15)
Windows Phone 7 (2)
Silverlight (4)

최근에 받은 트랙백

Total : 54,177
Today : 59 Yesterday : 64