PDA

View Full Version : [CLOSED] User Control in Code Behind



ucaneto
Mar 25, 2015, 7:07 PM
Hello all


I'm trying to show a usercontrol via code, made the screen and the usercontrol how do I show him when I click the button?

WebForm1.aspx


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Consorcio.Web.Sistema.Cadastros.WebForm1" %>


<%@ Register Src="~/Sistema/Cadastros/frmCotasMan.ascx" TagPrefix="uc1" TagName="frmCotasMan" %>




<!DOCTYPE html>


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<ext:ResourceManager runat="server" />
<ext:Button ID="btnIncluir" runat="server" Text="Adicionar" Icon="UserAdd" ToolTip="Adicionar um novo" OnDirectClick="btnIncluir_Click">
</ext:Button>
<uc1:frmCotasMan runat="server" ID="frmCotasMan" />
</div>
</form>
</body>
</html>




WebForm1.cs



using Ext.Net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


namespace Consorcio.Web.Sistema.Cadastros
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{


}


protected void btnIncluir_Click(object sender, DirectEventArgs e)
{
//???
}
}
}


frmCotasMan.ascx



<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="frmCotasMan.ascx.cs" Inherits="Consorcio.Web.Sistema.Cadastros.frmCotasMan" %>


<ext:Window ID="WindowCadastro" runat="server" Icon="Map" Title="Dados da Categoria"
Hidden="true" Modal="true" Width="1300" AutoHeight="true" Resizable="false" Closable="false">
<Items>
<ext:FormPanel ID="FormPanel1" runat="server" Padding="1" Layout="VBoxLayout" BodyStyle="background-color: transparent;" Frame="true" BodyPadding="1" Header="false" Visible="false">
<FieldDefaults LabelAlign="Right" LabelWidth="80" MsgTarget="Side" />


<Defaults>
<ext:Parameter Name="Border" Value="false" />
<ext:Parameter Name="Flex" Value="1" />
<ext:Parameter Name="Layout" Value="anchor" />
</Defaults>


<Items>
</Items>
</ext:FormPanel>
</Items>
</ext:Window>




Tks;

Daniil
Mar 26, 2015, 10:46 AM
Hi @ucaneto,

Please look at these example.
http://examples2.ext.net/#/XRender/UserControl/UpdateContent
http://examples2.ext.net/#/XRender/UserControl/Lazy_Load

ucaneto
Mar 26, 2015, 6:56 PM
Close the Thread.

Tks