Click here to Skip to main content
15,919,613 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Problem with Ajax update panel Pin
hozsam15-Jul-09 1:22
hozsam15-Jul-09 1:22 
Questionlistview HoverMenuExtender not working Pin
ademsandeepreddy14-Jul-09 23:07
ademsandeepreddy14-Jul-09 23:07 
QuestionRPC Server is Unavailable Pin
Sabari MD14-Jul-09 22:37
Sabari MD14-Jul-09 22:37 
AnswerRe: RPC Server is Unavailable Pin
Blue_Boy14-Jul-09 22:38
Blue_Boy14-Jul-09 22:38 
QuestionBest Method to Instantiate a Class Pin
Bardy8514-Jul-09 22:01
Bardy8514-Jul-09 22:01 
AnswerRe: Best Method to Instantiate a Class Pin
jc.net15-Jul-09 0:36
jc.net15-Jul-09 0:36 
GeneralRe: Best Method to Instantiate a Class Pin
Bardy8515-Jul-09 1:10
Bardy8515-Jul-09 1:10 
QuestionImplementation of iDatasource Interface Pin
pulak srivastava14-Jul-09 21:50
pulak srivastava14-Jul-09 21:50 
Hi All,

i have a custom control like below.


using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using System.IO;
using System.Collections.Specialized;
using System.Collections;


[assembly: TagPrefix("Tittle.Controls", "Tittle")]
namespace Tittle.Controls
{
#region Table Curve Panel Control (Expandable)
/// <summary>
/// Renders a tab control on page. i.e. A tabbed image on top of the table and you can have ur own contents in between that.
/// <example>
/// <code>
/// <Tittle:PanelCurveControl runat="server"
/// Expandable="true"
/// Width="500px"
/// Margin="10"
/// Title="Employees">
/// <table border=1>
/// <tr><td>test1</td><td>test2</td></tr>
/// <tr><td>test3</td><td>test4</td></tr>
/// </table>
/// </Tittle:PanelCurveControl>
/// </code>
/// </example>
/// <autor>Tittle Joseph (tittlejoseph@yahoo.com) India.</autor>
/// <url>http://www.codeproject.com/PanelCurveContainer/</url>
/// </summary>
[ToolboxData("<{0}:PanelCurveControl runat=server Expandable='true' id='tblCrvPnl' Width='200px'></{0}:PanelCurveControl>")]
public class PanelCurveControl : Panel, IPostBackDataHandler
{
private string skinName = ""; //"/BasicNuggetSkin";
private bool hasMinimize = true;
private bool hasPrint = true;
private string imgPath;
private Color bodyBackColor = Color.Transparent;
private string tabBackColor = "#99CCFF";
private string headerTextColor = "black";









public PanelCurveControl()
: base()
{

//imgPath = "/Images/";
}

/// <summary>
/// Makes the control expandable on demand,
/// Default: true
/// </summary>
[Browsable(true),
Category("Validation"),
DefaultValue("true"),
Description("Makes the control expandable on demand.")]
public bool Expandable
{
get { return Convert.ToBoolean(ViewState["Expandable"]); }
set { ViewState["Expandable"] = value; }
}

/// <summary>
/// Render the contents in the box
/// (used only if Expandable is false),
///
/// Expandable true makes tab disappear,
/// but if Expandable is false
/// RenderInBox is "true" shows border of container.
/// RenderInBox is "false" no border appears.
/// Default: false
/// </summary>
[Browsable(true),
Category("Misc"),
DefaultValue("false"),
Description("Render the contents in the box.")]
public bool RenderInBox
{
get { return Convert.ToBoolean(ViewState["RenderInBox"]); }
set { ViewState["RenderInBox"] = value; }
}

/// <summary>
/// Whether the contents of the expandable panel must be visible
/// Equivalent to "DefaultMinimize" attribute
/// Default: false
/// </summary>
[Browsable(true),
Category("Validation"),
DefaultValue("false"),
Description("Whether the contents of the expandable panel must be visible.")]
public bool Closed
{
get { return Convert.ToBoolean(ViewState["Closed"]); }
set { ViewState["Closed"] = value; }
}

/// <summary>
/// The text displayed as the caption of the expandable panel
///
/// Default: "Panel"
/// </summary>
[Browsable(true),
Category("Behavior"),
DefaultValue("Panel"),
Description("The text displayed as the caption of the expandable panel.")]
public string Title
{
get { return Convert.ToString(ViewState["Title"]); }
set { ViewState["Title"] = value; }
}

/// <summary>
/// The margin to use if the panel is expandable
///
/// Default: "2"
/// </summary>
[Browsable(true),
Category("Appearance"),
DefaultValue("2"),
Description("Margin to use if the panel is expandable.")]
public int Margin
{
get { return Convert.ToInt32(ViewState["Margin"]); }
set { ViewState["Margin"] = value; }
}

/// <summary>
/// SkinName to be used in nugget i.e. "BasicNuggetSkin", "BillInfoNuggetSkin", "DataGridNuggetSkin",
/// "TabbedNuggetSkin"
///
/// Default is "BasicNuggetSkin"
/// </summary>
[Browsable(true),
Category("Behavior"),
DefaultValue("BasicNuggetSkin"),
Description("Skinname to be used in nugget.")]
public string SkinName
{
get { return skinName; }
set { skinName = value; }
}

/// <summary>
/// Whether to show Minimize icon on screen or not.
///
/// Default: true
/// </summary>
[Browsable(true),
Category("Validation"),
DefaultValue("true"),
Description("Whether to show minimize icon on screen or not.")]
public bool HasMinimize
{
get { return hasMinimize; }
set { hasMinimize = value; }
}

/// <summary>
/// Whether to show Print icon on screen or not.
///
/// Default: true
/// </summary>
[Browsable(true),
Category("Validation"),
DefaultValue("true"),
Description("Whether to show Print icon on screen or not.")]
public bool HasPrint
{
get { return hasPrint; }
set { hasPrint = value; }
}

/// <summary>
/// Render it minmized by default or not
///
/// Default: false
/// </summary>
[Browsable(true),
Category("Appearance"),
DefaultValue("false"),
Description("Render it minimized by default or not.")]
public bool DefaultMinimize
{
get { return Closed; }
set { Closed = value; }
}

/// <summary>
/// Content Back Color
/// </summary>
public Color BodyBackColor
{
get { return bodyBackColor; }
set { bodyBackColor = value; }
}

/// <summary>
/// Top Tab Back Color
/// </summary>
public string TabBackColor
{
get { return tabBackColor; }
set { tabBackColor = value; }
}

/// <summary>
/// Top Header Text Color
/// </summary>
public string HeaderTextColor
{
get { return headerTextColor; }
set { headerTextColor = value; }
}

/// <summary>
///RaisePostDataChangedEvent::LoadPostData
/// Automatically updates the Closed property based on the content
/// of hidden field named as this control
/// </summary>
/// <param name="postDataKey"></param>
/// <param name="postCollection"></param>
/// <returns></returns>
public virtual bool LoadPostData(string postDataKey, NameValueCollection postCollection)
{
bool currentValueOfClosed = Closed;
bool postedValueOfClosed = Convert.ToBoolean(postCollection[postDataKey + "_hdnMinimizeState"]);

// What if the field is empty?
if (!currentValueOfClosed.Equals(postedValueOfClosed))
{
Closed = postedValueOfClosed;
return true;
}

return false;
}



/// <summary>
/// IPostBackDataHandler::RaisePostDataChangedEvent
/// </summary>
public virtual void RaisePostDataChangedEvent()
{
// Do nothing here
// No need of firing server-side events
}

/// <summary>
/// Fires when the panel gets loaded
/// </summary>
/// <param name="e"></param>
protected override void OnLoad(EventArgs e)
{
Expandable = true;
RenderInBox = false;
Title = "Panel";
Font.Name = "verdana";
Font.Size = FontUnit.Point(10);
Margin = 2;
Closed = false;
ForeColor = Color.Black;
BorderColor = Color.DodgerBlue;
imgPath = HttpContext.Current.Request.ApplicationPath + skinName + "/Images/";
base.OnLoad(e);

// Check the browser caps and disable collapse/expand if needed
bool uplevel = false;
HttpBrowserCapabilities caps = Page.Request.Browser;
if (caps.Browser.ToUpper().IndexOf("IE") > -1)
{
// This is IE. But is it at least v5?
if (caps.MajorVersion > 4)
uplevel = true;
}

// If the browser is not IE5 or higher, drop collapse/expand
if (!uplevel)
{
Expandable = false;
RenderInBox = true;
}

//Need to write this, so that LoadPostData() gets called.
Page.RegisterRequiresPostBack(this);
}

/// <summary>
/// Render the control
/// </summary>
/// <param name="output"></param>
protected override void Render(HtmlTextWriter output)
{
if (!Expandable)
{
if (!RenderInBox)
base.Render(output);
else
RenderContentsInBox(output);
return;
}

// Add margin information if the panel is expandable
Style["margin"] = Margin.ToString();
Style["display"] = (Closed ? "none" : "");

// The internal panel must cover 100% of the parent area
// irrespective of the physical width. We change this here
// so that the original Panel code doesn't reflect the
// external width.
Unit oldWidth = Width;
Width = Unit.Percentage(100);

//Add Hidden Field to maintain minimize/maximize state of the curve.
TextBox hdn = new TextBox();
hdn.Attributes.Add("style", "display:none");
//This is what created a big nuisance to me
if (this.UniqueID.IndexOf(":") >= 0)
hdn.ID = this.ID + "_hdnMinimizeState"; //Within some user control or grid //E.g. client id will be in this case "UserControl1__ctl0_tblCrvPnlControl2_hdnMinimizeState"
else
hdn.ID = this.UniqueID + "_hdnMinimizeState"; //Straight on aspx page, //E.g. client id will be in this case "tblCrvPnlControl1_hdnMinimizeState"

hdn.Text = Closed.ToString();
this.Controls.Add(hdn);

// Capture the default output of the Panel
StringWriter writer = new StringWriter();
HtmlTextWriter buffer = new HtmlTextWriter(writer);
base.Render(buffer);
string panelOutput = writer.ToString();

// Restore the wanted width because this affects the outer table
Width = oldWidth;
BuildControlTree(output, this.ClientID, panelOutput);
return;
}

// Handle the PreRender event
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);

CreateClientScript();
}

/// <summary>
/// Build the markup for this custom Panel control
/// </summary>
/// <param name="output"></param>
/// <param name="id"></param>
/// <param name="panelOutput"></param>
private void BuildControlTree(HtmlTextWriter output, string id, string panelOutput)
{
Table t = new Table();
//t.ID = "thePanel";
t.ID = id + "_thePanel";
t.CellPadding = 0;
t.CellSpacing = 0;
t.Width = Unit.Percentage(100); //Width;
t.HorizontalAlign = HorizontalAlign.Center;
t.Style.Add("margin", "0 0 0 0px");

// Prepare the topmost row
TableRow rowTop = new TableRow();

// Leftmost cell
TableCell leftCell = new TableCell();
leftCell.HorizontalAlign = HorizontalAlign.Left;
leftCell.Style.Add("width", "10px");
leftCell.Style.Add("background", tabBackColor + " url(" + imgPath + "topleft.gif) top left no-repeat");
leftCell.Text = "&nbsp;";
rowTop.Cells.Add(leftCell);

//Label Info
TableCell centerCell = new TableCell();
centerCell.Style.Add("background-Color", tabBackColor);
centerCell.Wrap = false;
centerCell.Attributes.Add("onselectstart", "return false"); //Not allowing user to select Tab Title text through mouse or double click.
if (hasMinimize == true)
centerCell.Attributes.Add("ondblclick", String.Format("javascript:MinMaxTableCurvePanel('{0}')", id));
Literal lit = new Literal();
lit.Text = String.Format("<P class=PanelCurveTitleStyle><font color='{1}'>{0}&nbsp;</font></P>", Title, headerTextColor);
centerCell.Controls.Add(lit);
rowTop.Cells.Add(centerCell);

//Print Icon Cell
if (hasPrint)
{
TableCell printCell = new TableCell();
//printCell.HorizontalAlign = HorizontalAlign.Right;
printCell.Style.Add("background-Color", tabBackColor);
printCell.Wrap = false;
printCell.Width = Unit.Pixel(20);
System.Web.UI.WebControls.Image imgPrint = new System.Web.UI.WebControls.Image();
imgPrint.AlternateText = "Print View";
imgPrint.BorderWidth = 0;
imgPrint.Style.Add("cursor", "hand");
imgPrint.Attributes.Add("onclick", String.Format("javascript:PrintTableCurvePanel('{0}')", id));
imgPrint.ImageAlign = ImageAlign.AbsMiddle;
imgPrint.ImageUrl = imgPath + "print.gif";
printCell.Controls.Add(imgPrint);
rowTop.Cells.Add(printCell);
}

//Minimize/Maximize Icon Cell
if (hasMinimize)
{
TableCell minimizeCell = new TableCell();
//minimizeCell.HorizontalAlign = HorizontalAlign.Right;
minimizeCell.Style.Add("background-Color", tabBackColor);
minimizeCell.Wrap = false;
minimizeCell.Width = Unit.Pixel(20);
System.Web.UI.WebControls.Image imgMinimize = new System.Web.UI.WebControls.Image();
//imgMinimize.ID = "img";
imgMinimize.ID = id + "_imgPlusMinus";
imgMinimize.AlternateText = "Minimize/Maximize the Panel";
imgMinimize.BorderWidth = 0;
imgMinimize.Style.Add("cursor", "hand");
imgMinimize.Attributes.Add("onclick", String.Format("javascript:MinMaxTableCurvePanel('{0}')", id));
imgMinimize.ImageAlign = ImageAlign.AbsMiddle;
imgMinimize.ImageUrl = imgPath + (Closed == true ? "plus.gif" : "minus.gif");
minimizeCell.Controls.Add(imgMinimize);
rowTop.Cells.Add(minimizeCell);
}

// Right most cell
TableCell rightCell = new TableCell();
rightCell.HorizontalAlign = HorizontalAlign.Right;
rightCell.Width = Unit.Pixel(10);
rightCell.Style.Add("width", "10px");
rightCell.Style.Add("background", tabBackColor + " url(" + imgPath + "topright.gif) top right no-repeat");
rightCell.Text = "&nbsp;";
rowTop.Cells.Add(rightCell);

// Add the top row to the table
t.Rows.Add(rowTop);

int colspan = 3;
if (hasPrint)
colspan++;
if (hasMinimize)
colspan++;

// Insert the Panel's markup in the table cell {Container}
TableRow rowBody = new TableRow();
if (bodyBackColor != Color.Transparent)
rowBody.BackColor = bodyBackColor;
TableCell cellBody = new TableCell();
cellBody.ColumnSpan = colspan;
cellBody.Text = panelOutput;
cellBody.Style.Add("BORDER", "#cccccc 1px solid");
cellBody.Style.Add("padding", "0 0 0 0px"); //"0 5 5 5px"
cellBody.Style.Add("margin", "0 0 0 0px"); //"0 0 5 0px"

rowBody.Cells.Add(cellBody);
t.Rows.Add(rowBody);

// Output
t.RenderControl(output);
}

/// <summary>
/// Add client side scripting
/// </summary>
private void CreateClientScript()
{
string jscript = @"
<style>
P.PanelCurveTitleStyle
{
font-family:verdana;
font-size: 12px;
font-weight : bold;
text-align: center;
}
</style>
<script language=javascript>
var imgPath='" + imgPath + @"';
</script>
<script language=javascript>
function MinMaxTableCurvePanel(cntrlId)
{
//Get state from hidden control.
var closed_TableCurvePanel = document.getElementById(cntrlId+'_hdnMinimizeState').value;
if ( closed_TableCurvePanel.toLowerCase() == 'true' )
{
document.getElementById(cntrlId).style.display = '';
document.getElementById(cntrlId+'_hdnMinimizeState').value=false;
document.getElementById(cntrlId+'_imgPlusMinus').src = imgPath + 'minus.gif';
}
else
{
document.getElementById(cntrlId).style.display = 'none';
document.getElementById(cntrlId+'_hdnMinimizeState').value = true;
document.getElementById(cntrlId+'_imgPlusMinus').src = imgPath + 'plus.gif';
}
}
//TODO: this could be improved further to show tab on new window.
function PrintTableCurvePanel(cntrlId)
{
var objDiv = document.getElementById(cntrlId);
var winTableCurvePanel = window.open('','winTableCurvePanelId','');
winTableCurvePanel.document.write('<html><head><title>Print</title></head><body onload=\'javascript:window.print()\'>');
winTableCurvePanel.document.write(objDiv.innerHTML);
winTableCurvePanel.document.write('</body></html>');
winTableCurvePanel.focus();
}
</script>
";

if (!Page.IsClientScriptBlockRegistered("TableCurvePanel_Script"))
Page.RegisterClientScriptBlock("TableCurvePanel_Script", jscript);
}

/// <summary>
/// Render the panel in a box (MSDN like)
/// </summary>
/// <param name="output"></param>
private void RenderContentsInBox(HtmlTextWriter output)
{
this.Style.Add("BORDER", "#cccccc 1px solid");
this.Style.Add("padding", "0 0 0 0px"); //"0 5 5 5px"
this.Style.Add("margin", "0 0 0 0px"); //"0 0 5 0px"

base.Render(output);
}









}





#endregion
}

Now i want to implement idatasource interface into this class.
like below


public class PanelCurveControl : Panel, IPostBackDataHandler,iDataSource




Can anybody help how to implement getview and getviewnames methord of idatasource interface.
QuestionServer Control Doesn't Work when placing google ads on the page Pin
Dhrumil_Shukla14-Jul-09 21:47
Dhrumil_Shukla14-Jul-09 21:47 
Questiondefault.aspx.cs can not see classes added in App_Code folder Pin
Chesnokov Yuriy14-Jul-09 21:02
professionalChesnokov Yuriy14-Jul-09 21:02 
AnswerRe: default.aspx.cs can not see classes added in App_Code folder Pin
freshers14-Jul-09 21:22
freshers14-Jul-09 21:22 
AnswerRe: default.aspx.cs can not see classes added in App_Code folder Pin
Chesnokov Yuriy14-Jul-09 22:00
professionalChesnokov Yuriy14-Jul-09 22:00 
AnswerRe: default.aspx.cs can not see classes added in App_Code folder Pin
K030614-Jul-09 21:23
K030614-Jul-09 21:23 
QuestionRe: default.aspx.cs can not see classes added in App_Code folder Pin
Chesnokov Yuriy14-Jul-09 21:59
professionalChesnokov Yuriy14-Jul-09 21:59 
AnswerRe: default.aspx.cs can not see classes added in App_Code folder Pin
himanshu256114-Jul-09 21:25
himanshu256114-Jul-09 21:25 
GeneralRe: default.aspx.cs can not see classes added in App_Code folder Pin
freshers14-Jul-09 21:28
freshers14-Jul-09 21:28 
GeneralRe: default.aspx.cs can not see classes added in App_Code folder Pin
himanshu256114-Jul-09 21:34
himanshu256114-Jul-09 21:34 
GeneralRe: default.aspx.cs can not see classes added in App_Code folder Pin
freshers14-Jul-09 21:41
freshers14-Jul-09 21:41 
GeneralRe: default.aspx.cs can not see classes added in App_Code folder Pin
himanshu256114-Jul-09 21:52
himanshu256114-Jul-09 21:52 
QuestionRe: default.aspx.cs can not see classes added in App_Code folder Pin
Chesnokov Yuriy14-Jul-09 22:03
professionalChesnokov Yuriy14-Jul-09 22:03 
AnswerResolved - Re: default.aspx.cs can not see classes added in App_Code folder Pin
Chesnokov Yuriy14-Jul-09 22:06
professionalChesnokov Yuriy14-Jul-09 22:06 
QuestionProblem with membership provider DB created using ASP.NET configuration Pin
ptr_Electron14-Jul-09 21:01
ptr_Electron14-Jul-09 21:01 
AnswerRe: Problem with membership provider DB created using ASP.NET configuration Pin
r a m e s h15-Jul-09 0:40
r a m e s h15-Jul-09 0:40 
QuestionMail is not reached Pin
Kissy1614-Jul-09 20:56
Kissy1614-Jul-09 20:56 
AnswerRe: Mail is not reached Pin
SeMartens14-Jul-09 21:15
SeMartens14-Jul-09 21:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.