0

i have a problem with ext.net. i am new in ext.net and i cannot use add stored procedure with it like i have done before in .net framework.

here is my asp code:

<ext:Panel ID="Panel1" runat="server" Title="Add Customer" PaddingSummary="5px 5px 0"
        Width="790px" Frame="true" ButtonAlign="Center" Layout="Form">
        <Items>
            <ext:TextField ID="name" runat="server" FieldLabel="First Name" AllowBlank="false"
                AnchorHorizontal="100%" />
            <ext:TextField ID="surname" runat="server" FieldLabel="Last Name" AllowBlank="false"
                AnchorHorizontal="100%" />
            <ext:TextField ID="tcno" runat="server" FieldLabel="Citizenship Number" AnchorHorizontal="100%" />
            <ext:TextField ID="mphone" runat="server" FieldLabel="Mobile Phone" AnchorHorizontal="100%" />
            <ext:TextField ID="hphone" runat="server" FieldLabel="Home Phone" AnchorHorizontal="100%" />
            <ext:TextField ID="wphone" runat="server" FieldLabel="Work Phone" AnchorHorizontal="100%" />
            <ext:TextField ID="haddress" runat="server" FieldLabel="Home Adress" AnchorHorizontal="100%" />
            <ext:TextField ID="waddress" runat="server" FieldLabel="Work Adress" AnchorHorizontal="100%" />
            <ext:TextField ID="email" runat="server" FieldLabel="Email" Vtype="email" AnchorHorizontal="100%" />
        </Items>
        <Buttons>
            <ext:Button ID="Button1" runat="server" Text="Submit">
                <Listeners>
                    <Click Handler="Ext.net.DirectMethods.addClient();" />
                </Listeners>
            </ext:Button>
            <ext:Button ID="Button2" runat="server" Text="Cancel"/>            
        </Buttons>        
    </ext:Panel>

and .cs file is that:

protected void Page_Load(object sender, EventArgs e)
    {

    }

    [DirectMethod]
    public void addClient()
    {
        SqlConnection myConnection;
        SqlCommand myCommand;            

        string strConn = System.Configuration.ConfigurationManager.ConnectionStrings["SiyahBayrakConnectionString"].ConnectionString;

        myConnection = new SqlConnection(strConn);
        myConnection.Open();
        myCommand = new SqlCommand("addClient", myConnection);
        myCommand.CommandType = System.Data.CommandType.StoredProcedure;

        myCommand.Parameters.AddWithValue("@name", this.name);
        myCommand.Parameters.AddWithValue("@surName", this.surname);
        myCommand.Parameters.AddWithValue("@tcNo", this.tcno);
        myCommand.Parameters.AddWithValue("@mobilePhone", this.mphone);
        myCommand.Parameters.AddWithValue("@homePhone", this.hphone);
        myCommand.Parameters.AddWithValue("@workPhone", this.wphone);
        myCommand.Parameters.AddWithValue("@homeAddress", this.haddress);
        myCommand.Parameters.AddWithValue("@workAddress", this.waddress);
        myCommand.Parameters.AddWithValue("@email", this.email);
    }    

my stored procedure is working but the add function does not work. nothing happens and there is nothing in database after click submit. what is the problem?

4

2 回答 2

0

检查你的语法,然后试试这个 App.direct.addClient(); 而不是 Ext.net.DirectMethods.addClient();

它们实际上是相同的东西,但我不确定它是否可以更改取决于您使用 ext.net 的版本。

但在我看来,您的代码是正确的,并且问题与 ext.net 无关。

于 2013-10-11T11:43:50.377 回答
0

如果您只想从按钮单击事件中调用方法,我倾向于使用以下语法:

<ext:Button .../>
    <DirectEvents>
        <Click OnEvent="addClient"/>
    </DirectEvents>
</ext:Button>

当您想使用基于您的按钮单击的 JavaScript 方法时,使用处理程序,尝试使用 DirectEvents 来触发对服务器端方法的 Ajax 请求。

于 2011-12-19T17:10:56.673 回答