Aug 13, 2012, 1:28 PM
UserControl Direct Method is not Firing...
Hai Frnds when i am trying to call the Direct method in UserControl, it is not firing, anybody help me
here is my sample code files like ContactForm1.ascx page and ContactForm.aspx page
here is my sample code files like ContactForm1.ascx page and ContactForm.aspx page
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ContactForm1.ascx.cs"
Inherits="ContactForm1" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
public void btnsave_click()
{
System.Data.SqlClient.SqlConnection cn = new System.Data.SqlClient.SqlConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings["con"].ConnectionString);
cn.Open();
string q = "insert into Details (firstname,lastname,emailid,address,phone,pin) values('" + txtfirst.Text + "','" + txtlast.Text + "','" + txtemail.Text + "','" + txtaddress.Text + "','" + numphone.Text + "','" + numpin.Text + "')";
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(q, cn);
cmd.ExecuteNonQuery();
cn.Close();
}
</script>
<ext:Window ID="Window1" runat="server" Title="Details" Width="400" Height="380"
Layout="FitLayout" Resizable="true" Modal="true" DefaultButton="btnSave">
<Items>
<ext:FormPanel ID="fp1" runat="server" Border="false" AutoDoLayout="true" BodyPadding="10">
<LayoutConfig>
<ext:VBoxLayoutConfig Align="Stretch" />
</LayoutConfig>
<FieldDefaults LabelAlign="Top" LabelWidth="100" LabelStyle="font-weight:bold;" />
<Items>
<ext:FieldContainer ID="FieldContainer1" runat="server" FieldLabel="Your Name" LabelStyle="font-weight:bold;padding:0;"
Layout="HBoxLayout">
<FieldDefaults LabelAlign="Top" />
<Items>
<ext:TextField ID="txtfirst" runat="server" Flex="1" Name="firstName" FieldLabel="First"
AllowBlank="false">
<AfterLabelTextTpl ID="AfterLabelTextTpl1" runat="server">
<Html>
<span style="color: red; font-weight: bold" data-qtip="Required">*</span>
</Html>
</AfterLabelTextTpl>
</ext:TextField>
<ext:TextField runat="server" ID="txtlast" Flex="2" Name="lastName" FieldLabel="Last"
AllowBlank="false" Margins="0 0 0 5">
<AfterLabelTextTpl ID="AfterLabelTextTpl2" runat="server">
<Html>
<span style="color: red; font-weight: bold" data-qtip="Required">*</span>
</Html>
</AfterLabelTextTpl>
</ext:TextField>
</Items>
</ext:FieldContainer>
<ext:TextField runat="server" ID="txtemail" FieldLabel="Your Email Address" Vtype="email"
AllowBlank="false">
<AfterLabelTextTpl ID="AfterLabelTextTpl3" runat="server">
<Html>
<span style="color: red; font-weight: bold" data-qtip="Required">*</span>
</Html>
</AfterLabelTextTpl>
</ext:TextField>
<ext:TextField runat="server" ID="txtaddress" FieldLabel="Address" AllowBlank="false">
<AfterLabelTextTpl ID="AfterLabelTextTpl4" runat="server">
<Html>
<span style="color: red; font-weight: bold" data-qtip="Required">*</span>
</Html>
</AfterLabelTextTpl>
</ext:TextField>
<ext:NumberField runat="server" ID="numphone" AllowBlank="false" FieldLabel="Phone No"
MaxLength="10" MinLength="10">
<AfterLabelTextTpl ID="AfterLabelTextTpl5" runat="server">
<Html>
<span style="color: red; font-weight: bold" data-qtip="Required">*</span>
</Html>
</AfterLabelTextTpl>
</ext:NumberField>
<ext:NumberField runat="server" ID="numpin" AllowBlank="false" FieldLabel="Pin Code"
MaxLength="6" MinLength="6">
<AfterLabelTextTpl ID="AfterLabelTextTpl6" runat="server">
<Html>
<span style="color: red; font-weight: bold" data-qtip="Required">*</span>
</Html>
</AfterLabelTextTpl>
</ext:NumberField>
</Items>
<Buttons>
<ext:Button runat="server" Text="Cancel" ID="btncancel">
<Listeners>
<Click Handler="this.up('form').getForm().reset(); this.up('window').hide();" />
</Listeners>
</ext:Button>
<ext:Button runat="server" Text="Send" ID="btnSave" FormBind="true" >
<Listeners>
<Click Handler="#{DirectMethods}.btnsave_click();" />
</Listeners>
</ext:Button>
</Buttons>
</ext:FormPanel>
</Items>
</ext:Window>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ContactForm.aspx.cs" Inherits="ContactForm" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script runat="server">
protected void ShowContactForm(object sender, Ext.Net.DirectEventArgs e)
{
var config = new Ext.Net.UserControlRendrerConfig
{
UserControlPath = "ContactForm1.ascx",
SingleControl = true,
Mode = Ext.Net.RenderMode.RenderTo,
Element = this.Form.ClientID
};
config.BeforeRender += delegate(Ext.Net.ComponentAddedEventArgs ce)
{
ce.Control.ID = Ext.Net.BaseControl.GenerateID();
e.ExtraParamsResponse.Add(new Ext.Net.Parameter("windowId", ce.Control.ConfigID));
};
Ext.Net.UserControlRenderer.Render(config);
}
</script>
<style type="text/css">
.contactBtn button
{
padding: 0 5px;
font-size: 16px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<ext:ResourceManager runat="server">
</ext:ResourceManager>
<ext:Panel ID="Panel1" runat="server" Title="Welcome!" Width="200" BodyPadding="20">
<Items>
<ext:Container ID="Container1" runat="server" StyleSpec="text-align:center">
<Items>
<ext:Button ID="Button1" runat="server" Cls="contactBtn" Scale="Large" Text="Insert Details">
<DirectEvents>
<Click OnEvent="ShowContactForm" Single="true" Success="this.windowId = result.extraParamsResponse.windowId; this.on('click', function(){Ext.getCmp(this.windowId).show();}, this);" />
</DirectEvents>
</ext:Button>
</Items>
</ext:Container>
</Items>
</ext:Panel>
</div>
</form>
</body>
</html>
Thanks