Initial import
This commit is contained in:
23
WebControls/Properties/AssemblyInfo.cs
Normal file
23
WebControls/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Web.UI;
|
||||
|
||||
// Information about this assembly is defined by the following attributes.
|
||||
// Change them to the values specific to your project.
|
||||
[assembly: AssemblyTitle ("WebControls")]
|
||||
[assembly: AssemblyDescription ("")]
|
||||
[assembly: AssemblyConfiguration ("")]
|
||||
[assembly: AssemblyCompany ("")]
|
||||
[assembly: AssemblyProduct ("")]
|
||||
[assembly: AssemblyCopyright ("Paul Schneider")]
|
||||
[assembly: AssemblyTrademark ("")]
|
||||
[assembly: AssemblyCulture ("")]
|
||||
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
|
||||
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
|
||||
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
|
||||
[assembly: AssemblyVersion ("1.0.*")]
|
||||
// The following attributes are used to specify the signing key for the assembly,
|
||||
// if desired. See the Mono documentation for more information about signing.
|
||||
//[assembly: AssemblyDelaySign(false)]
|
||||
//[assembly: AssemblyKeyFile("")]
|
||||
[assembly: TagPrefix("Yavsc.WebControls", "yavsc")]
|
116
WebControls/ResultPages.cs
Normal file
116
WebControls/ResultPages.cs
Normal file
@ -0,0 +1,116 @@
|
||||
using System;
|
||||
using System.Web;
|
||||
using System.Security.Permissions;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Yavsc.WebControls
|
||||
{
|
||||
[
|
||||
AspNetHostingPermission (SecurityAction.Demand,
|
||||
Level = AspNetHostingPermissionLevel.Minimal),
|
||||
AspNetHostingPermission (SecurityAction.InheritanceDemand,
|
||||
Level = AspNetHostingPermissionLevel.Minimal),
|
||||
ParseChildren (true, "Action"),
|
||||
DefaultProperty ("Action"),
|
||||
ToolboxData ("<{0}:ResultPages runat=\"server\"> </{0}:ResultPages>")
|
||||
]
|
||||
public class ResultPages: WebControl
|
||||
{
|
||||
public ResultPages ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
[Bindable (true)]
|
||||
[DefaultValue(10)]
|
||||
public int ResultsPerPage {
|
||||
get {
|
||||
return (int)( ViewState["ResultsPerPage"]==null?10:ViewState["ResultsPerPage"]);
|
||||
}
|
||||
set {
|
||||
ViewState["ResultsPerPage"]=value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Bindable (true)]
|
||||
[DefaultValue(0)]
|
||||
public int ResultCount {
|
||||
get {
|
||||
|
||||
return (int)( ViewState["ResultCount"]==null?0:ViewState["ResultCount"]);
|
||||
}
|
||||
set {
|
||||
ViewState["ResultCount"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[Bindable (true)]
|
||||
[DefaultValue("Pages:")]
|
||||
[Localizable(true)]
|
||||
public string Text {
|
||||
get {
|
||||
|
||||
string s = (string)ViewState["Text"];
|
||||
return (s == null) ? "Pages:" : s;
|
||||
}
|
||||
set {
|
||||
ViewState["Text"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[Bindable (true)]
|
||||
[DefaultValue("")]
|
||||
public string Action {
|
||||
get {
|
||||
|
||||
string s = (string)ViewState["Action"];
|
||||
return (s == null) ? String.Empty : s;
|
||||
}
|
||||
set {
|
||||
ViewState["Action"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Bindable (true)]
|
||||
[DefaultValue(0)]
|
||||
public int CurrentPage {
|
||||
get {
|
||||
int i = (int)(ViewState["CurrentPage"]==null?0:ViewState["CurrentPage"]);
|
||||
return i;
|
||||
}
|
||||
set {
|
||||
ViewState["CurrentPage"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void RenderContents (HtmlTextWriter writer)
|
||||
{
|
||||
if (ResultCount > 0) {
|
||||
writer.WriteEncodedText (Text);
|
||||
int pageCount = ((ResultCount-1) / ResultsPerPage) + 1;
|
||||
for (int pi = (CurrentPage < 5) ? 0 : CurrentPage - 5; pi < pageCount && pi < CurrentPage + 5; pi++) {
|
||||
if (CurrentPage == pi)
|
||||
writer.RenderBeginTag ("b");
|
||||
else {
|
||||
writer.AddAttribute (HtmlTextWriterAttribute.Href,
|
||||
string.Format (Action, pi));
|
||||
writer.RenderBeginTag ("a");
|
||||
|
||||
}
|
||||
writer.Write (pi);
|
||||
writer.RenderEndTag ();
|
||||
writer.Write (" ");
|
||||
}
|
||||
writer.Write ("("+ResultCount.ToString()+" resultat(s))");
|
||||
} else {
|
||||
writer.Write ("(Pas de resultat)");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
49
WebControls/WebControls.csproj
Normal file
49
WebControls/WebControls.csproj
Normal file
@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>10.0.0</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{59E1DF7B-FFA0-4DEB-B5F3-76EBD98D5356}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>WebControls</RootNamespace>
|
||||
<AssemblyName>Yavsc.WebControls</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
<Reference Include="System.Web.DynamicData" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Abstractions" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ResultPages.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
Reference in New Issue
Block a user