Can't understand how to use DevExpress tab control - c#

I can't get how to use DevExpress tab control. I dragged control and added three tabs, and when I try to put a content inside proper tags, it says that DevExpress.Web.ASPxTabControl.Tab doesn't have public property named div.
Here is the code:
<%# Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="AddNews.aspx.cs" Inherits="MarketingAdmin.EditNews" %>
<%# Register Assembly="DevExpress.Web.v12.1, Version=12.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.Web.ASPxTabControl" TagPrefix="dx" %>
<%# Register Assembly="DevExpress.Web.ASPxEditors.v12.1, Version=12.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
<%# Register Assembly="DevExpress.Web.ASPxHtmlEditor.v12.1, Version=12.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.Web.ASPxHtmlEditor" TagPrefix="dx" %>
<%# Register assembly="DevExpress.Web.ASPxSpellChecker.v12.1, Version=12.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxSpellChecker" tagprefix="dx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<dx:ASPxTabControl ID="ASPxTabControl1" runat="server" ActiveTabIndex="0"
EnableTheming="True" Theme="Glass">
<Tabs>
<dx:Tab Text="Казахский" >
<div style="font-family=Times New Roman; font-size:medium ">Категория
<asp:DropDownList ID="CategoryDropDownList" runat="server"
DataSourceID="SqlDataSource1" DataTextField="Name" DataValueField="id" ></asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:MarketingConnectionString %>"
SelectCommand="SELECT [Name], [id] FROM [NewsCategory]"></asp:SqlDataSource>
</div>
<div style="font-family=Times New Roman; font-size:medium "> Заголовок
<asp:TextBox ID="TitleTextBox" runat="server" Width="610px"></asp:TextBox></div>
<dx:ASPxHtmlEditor ID="ASPxHtmlEditor1" runat="server">
</dx:ASPxHtmlEditor>
</dx:Tab>
<dx:Tab Text="Русский">
content 2
</dx:Tab>
<dx:Tab Text="Английский">
content 3
</dx:Tab>
</Tabs>
</dx:ASPxTabControl>
<asp:Button ID="SaveButton" runat="server" Text="Сохранить"
onclick="SaveButton_Click" />
</asp:Content>
Can anybody help me?

Based on what you're asking, I believe you need to use the ASPxPageControl. The ASPxTabControl is only to create a tabstrip with no actual "tabs" below the strip. It is best used for site navigation.

Related

Show a calendar extendar within Asp.net application

I have an Asp.net application in which i'd like to add a calendar extendar. So i use this code:
<%# Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Home.aspx.vb" Inherits="Home" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<cc1:ToolkitScriptManager ID="ScriptManager1" runat="server" EnableScriptGlobalization="true"></cc1:ToolkitScriptManager>
<span style=" margin-left: 60%">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="error1" Text="error1" ControlToValidate="FirstDate" ForeColor="Red" Font-Bold="true"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="error2" Text="error2" ControlToValidate="FirstDate" ValidationExpression="^[0-3]+[0-9]\/[0-1]+[0-9]\/[0-9]{4}" ForeColor="Red" Font-Bold="true"></asp:RegularExpressionValidator>
<asp:TextBox ID="FirstDate" runat="server" ></asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="FirstDate" CssClass="test">
</cc1:CalendarExtender>
</span>
</asp:Content>
The problem is : when i click into the TextBox the calendar isn't shown :
Why this happens?
How can i modify my code to fix this error?
I don't believe that the CalendarExtender behaves the way you're expecting. At least, it doesn't for me. What I usually do is add an ImageButton and make the CalendarExtender's PopupButtonID equal to the ImageButton's ID.

Returning IEnumerable<T[]> with ObjectDataSource to use in ListView

I Want use IEnumerable that I get from an ObjectDataSource. I dont know How I can use "Eval" or something like that in an Item of type IEnumerable, I thought use the foreach But I dont Know How Binding the data, Some Ideas?.
The Method
public IEnumerable<Suppliers[]> ListaProveedores()
{
return ProveedoresCortadosEn3();
}
The ASPX
<%# Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Proveedores.aspx.cs" Inherits="JugandoConNorthWind.Proveedores.Proveedores" %>
<asp:Content ID="Main" ContentPlaceHolderID="MainPlaceHolder" runat="server">
<form id="form1" runat="server">
<div class="container">
<h1>Proveedores</h1>
<asp:ListView ID="LVProveedores" runat="server" DataSourceID="ObjectDataSource1">
<ItemTemplate>
</ItemTemplate>
</asp:ListView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="ListaProveedores" TypeName="JugandoConNorthWind.Proveedores.Proveedores"> </asp:ObjectDataSource>
</div>
</form>

fire a textbox's OnTextChanged while enabled=false

I have an ajax toolkit calendar extender attached to my textbox and i a trying to fire the OnTextChanged after the date was entered into the textbox.
The thing is i don't want the user to enter data manually so i disabled the textbox but the event won't fire for a disabled text box.
is there anyway around it? i thought about changing to a label but is doesn't have OnTextChanged event.
Thanks
<asp:TableCell CssClass="cssWidth" Width="150px">
<asp:CalendarExtender ID="CalendarExtender1" PopupButtonID="Image1" runat="server" TargetControlID="TextBoxAddDate" Format="dd/MM/yyyy"></asp:CalendarExtender>
<asp:TextBox ID="TextBoxAddDate" ReadOnly="true" CssClass="cssWidth" ToolTip="תאריך הוספה" runat="server" Style="font-size: large;background-color:aliceblue;" AutoPostBack="true" AutoCompleteType="Search" MaxLength="0" TextMode="SingleLine" OnTextChanged="txtSearch_TextChanged" ViewStateMode="Enabled" autocomplete="off" >
</asp:TextBox>&nbsp
<asp:ImageButton runat="Server" ID="Image1"
ImageUrl="~/Calendar_scheduleHS.png" AlternateText="Click to show calendar" /><br />
</asp:TableCell>
Can you use ReadOnly instead of Enabled = false?
UPDATE:
Ok, this is the complete solution that worked for me:
<%# Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<script type="text/javascript">
function dateSelectionChanged(x) {
debugger;
javascript: __doPostBack('TextBoxAddDate', '')
}
</script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<h2>
Welcome to ASP.NET!
</h2>
<p>
To learn more about ASP.NET visit www.asp.net.
</p>
<p>
You can also find <a href="http://go.microsoft.com/fwlink/?LinkID=152368&clcid=0x409"
title="MSDN ASP.NET Docs">documentation on ASP.NET at MSDN</a>.
</p>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:CalendarExtender ID="CalendarExtender1" PopupButtonID="Image1" runat="server" TargetControlID="TextBoxAddDate" Format="dd/MM/yyyy" OnClientDateSelectionChanged="dateSelectionChanged" ></asp:CalendarExtender>
<asp:TextBox ID="TextBoxAddDate" CssClass="cssWidth" ToolTip="תאריך הוספה" runat="server" Style="font-size: large;background-color:aliceblue;" AutoCompleteType="Search" MaxLength="0" TextMode="SingleLine" OnTextChanged="txtSearch_TextChanged" ViewStateMode="Enabled">
</asp:TextBox>&nbsp
<asp:ImageButton runat="Server" ID="Image1"
ImageUrl="~/Calendar_scheduleHS.png" AlternateText="Click to show calendar" /><br />
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
It seems that the CalendarExtender "steals" away the events from the texbox it uses.
Using this approach I managed to fire up the OnTextChanged event and the handler txtSearch_TextChanged gets executed.
Did you make the textbox ReadOnly?

AjaxToolKit CalendarExtender Problems

In my Summary page, I have two CalendarExtender controls to enable someone to select Start Date and End Date for database queries.
In the head of my Summary.aspx page, I have the following declarations:
<%# MasterType VirtualPath="~/Site.Master" %>
<%# Page Title="ACP Sheet Metal - Summary" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Summary.aspx.cs" Inherits="AcpSheetMetal.Summary" UICulture="es" Culture="es-MX" %>
<% #Import Namespace="System.Globalization" %>
<%# Register TagPrefix="asp" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit"%>
For the page itself, I have a ToolkitScriptManager, two (2) TextBox controls, two CalendarExtender controls, and a GridView control:
<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager2" runat="server" EnableScriptGlobalization="true" EnableScriptLocalization="true" />
<asp:TextBox ID="txtStartDate" runat="server" />
<asp:CalendarExtender ID="calExStartDate" runat="server" TargetControlID="txtStartDate" OnClientShown="ChangeCalendarView" OnClientDateSelectionChanged="checkDate" />
<asp:TextBox ID="txtEndDate" runat="server" />
<asp:CalendarExtender ID="calExEndDate" runat="server" TargetControlID="txtEndDate" OnClientShown="ChangeCalendarView" OnClientDateSelectionChanged="checkDate" DaysModeTitleFormat="MM/dd/yyyy" DefaultView="Months" Enabled="True" TodaysDateFormat="MMMM dd, yyyy" />
<asp:GridView ID="summaryGridView" runat="server" />
In the Page_Load event in the C# code, I have placed the following:
protected void Page_Load(object sender, EventArgs e) {
MasterPage = (SiteMaster)Page.Master;
if (!Page.IsPostBack) {
calExEndDate.TodaysDateFormat = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;
calExStartDate.TodaysDateFormat = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;
}
}
So, why are my Calendar controls not working? There are no values in the calendars and the language appears to be Spanish.
Just add EnableScriptGlobalization="true" in your ScriptManager like this:
Your language is Spanish and I believe it's so because your UICulture is UICulture="es" (ESpañol) and Culture="es-MX" (Español México).
See this line on your markup:
<%# Page Title="ACP Sheet Metal - Summary" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Summary.aspx.cs" Inherits="AcpSheetMetal.Summary" UICulture="es" Culture="es-MX" %>
The rest of your markup looks okay to me.

Error while deleting all child controls from the parent control

I have the next aspx page:
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true"
CodeBehind="newsEditor.aspx.cs" Inherits="ExpertSiteV2.newsEditor" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%# Register Assembly="ExpertSiteV2" Namespace="ExpertSiteV2" TagPrefix="custom" %>
<asp:Content ID="Content3" ContentPlaceHolderID="Main" runat="server">
<asp:Panel ID="Panel1" runat="server">
<asp:Panel ID="Panel2" runat="server" Width="660" Style="margin-bottom: 10px;">
<asp:Label ID="Label1" runat="server" Text="Label" Width="150">Заголовок новости</asp:Label>
<asp:TextBox ID="newsTitle" runat="server" Width="500" Style="float: right;"></asp:TextBox>
</asp:Panel>
<custom:CustomEditor ID="Editor3" runat="server" Height="300" Width="660" BackColor="White" />
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:Panel ID="Panel3" runat="server" Style="margin-top: 5px;" CssClass="buttonPanel">
<asp:ImageButton ID="SaveImageButton1" runat="server" ImageUrl="img/save_32.png"
ToolTip="Сохранить новость" />
<asp:LinkButton ID="SaveLinkButton1" runat="server" ToolTip="Сохранить новость">Сохранить</asp:LinkButton>
<asp:ImageButton ID="ImageButton2" runat="server" CausesValidation="False" ImageUrl="img/block_32.png"
PostBackUrl="news.aspx" ToolTip="Вернуться к странице новостей" />
<asp:LinkButton ID="LinkButton2" runat="server" ToolTip="Вернуться к странице новостей"
CausesValidation="False" PostBackUrl="news.aspx">Отмена</asp:LinkButton>
</asp:Panel>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Заголовок должен быть заполнен!"
ControlToValidate="newsTitle" Display="Dynamic">
</asp:RequiredFieldValidator>
</asp:Panel>
</asp:Content>
I want to delete all the contents of Panel1. I write the code:
Panel1.Controls.Clear();
But it doesn't work and I get the message:
Page cannot be null. Please ensure
that this operation is being performed
in the context of an ASP.NET request.
Description: An unhandled exception
occurred during the execution of the
current web request. Please review the
stack trace for more information about
the error and where it originated in
the code.
Exception Details:
System.InvalidOperationException: Page
cannot be null. Please ensure that
this operation is being performed in
the context of an ASP.NET request.
Source Error:
An unhandled exception was generated
during the execution of the current
web request. Information regarding the
origin and location of the exception
can be identified using the exception
stack trace below.
Stack Trace:
[InvalidOperationException: Page
cannot be null. Please ensure that
this operation is being performed in
the context of an ASP.NET request.]
System.Web.UI.ScriptManager.get_IPage()
+373832 System.Web.UI.ScriptManager.OnPagePreRenderComplete(Object
sender, EventArgs e) +54
System.Web.UI.Page.OnPreRenderComplete(EventArgs
e) +8698462
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean
includeStagesAfterAsyncPoint) +1029
Blockquote
What's wrong? How should I do it properly?
Okay, i've written something like this:
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true"
CodeBehind="newsEditor.aspx.cs" Inherits="ExpertSiteV2.newsEditor" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%# Register Assembly="ExpertSiteV2" Namespace="ExpertSiteV2" TagPrefix="custom" %>
<asp:Content ID="Content3" ContentPlaceHolderID="Main" runat="server">
<asp:Panel ID="Panel4" runat="server">
<asp:Panel ID="Panel1" runat="server">
<asp:Panel ID="Panel2" runat="server" Width="660" Style="margin-bottom: 10px;">
<asp:Label ID="Label1" runat="server" Text="Label" Width="150">Заголовок новости</asp:Label>
<asp:TextBox ID="newsTitle" runat="server" Width="500" Style="float: right;"></asp:TextBox>
</asp:Panel>
<custom:CustomEditor ID="Editor3" runat="server" Height="300" Width="660" BackColor="White" />
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:Panel ID="Panel3" runat="server" Style="margin-top: 5px;" CssClass="buttonPanel">
<asp:ImageButton ID="SaveImageButton1" runat="server" ImageUrl="img/save_32.png"
ToolTip="Сохранить новость" />
<asp:LinkButton ID="SaveLinkButton1" runat="server" ToolTip="Сохранить новость">Сохранить</asp:LinkButton>
<asp:ImageButton ID="ImageButton2" runat="server" CausesValidation="False" ImageUrl="img/block_32.png"
PostBackUrl="news.aspx" ToolTip="Вернуться к странице новостей" />
<asp:LinkButton ID="LinkButton2" runat="server" ToolTip="Вернуться к странице новостей"
CausesValidation="False" PostBackUrl="news.aspx">Отмена</asp:LinkButton>
</asp:Panel>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Заголовок должен быть заполнен!"
ControlToValidate="newsTitle" Display="Dynamic">
</asp:RequiredFieldValidator>
</asp:Panel>
</asp:Panel>
</asp:Content>
Here is one more panel that contains everything. And I've written:
Panel4.Controls.Clear();
It works fine.
I still don't know why the Panel1 doesn't want to remove child controls. If someone knows just write the answer.
Can't you not just hide the panel? Panel1.Visible = false. why do you wanna remove the controls.
Aha ok I get the question now:
Check out this project, http://www.codeproject.com/KB/user-controls/DynamicUC.aspx

Categories