// Authors:
// Lluis Sanchez Gual (lluis@novell.com)
//
-// (C) 2005 Novell, Inc (http://www.novell.com)
+// (C) 2005-2010 Novell, Inc (http://www.novell.com)
//
//
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if NET_2_0
using System.Collections;
using System.Collections.Specialized;
using System.Web.UI;
using System.Security.Permissions;
using System.Reflection;
-namespace System.Web.UI.WebControls {
-
+namespace System.Web.UI.WebControls
+{
[AspNetHostingPermissionAttribute (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class HyperLinkField : DataControlField
public virtual string[] DataNavigateUrlFields {
get {
object ob = ViewState ["DataNavigateUrlFields"];
- if (ob != null) return (string[]) ob;
- if (emptyFields == null) emptyFields = new string[0];
+ if (ob != null)
+ return (string[]) ob;
+ if (emptyFields == null)
+ emptyFields = new string[0];
return emptyFields;
}
set {
public virtual string DataNavigateUrlFormatString {
get {
object ob = ViewState ["DataNavigateUrlFormatString"];
- if (ob != null) return (string) ob;
- return "";
+ if (ob != null)
+ return (string) ob;
+ return String.Empty;
}
set {
ViewState ["DataNavigateUrlFormatString"] = value;
public virtual string DataTextField {
get {
object ob = ViewState ["DataTextField"];
- if (ob != null) return (string) ob;
- return "";
+ if (ob != null)
+ return (string) ob;
+ return String.Empty;
}
set {
ViewState ["DataTextField"] = value;
public virtual string DataTextFormatString {
get {
object ob = ViewState ["DataTextFormatString"];
- if (ob != null) return (string) ob;
- return "";
+ if (ob != null)
+ return (string) ob;
+ return String.Empty;
}
set {
ViewState ["DataTextFormatString"] = value;
public virtual string NavigateUrl {
get {
object ob = ViewState ["NavigateUrl"];
- if (ob != null) return (string) ob;
- return "";
+ if (ob != null)
+ return (string) ob;
+ return String.Empty;
}
set {
ViewState ["NavigateUrl"] = value;
public virtual string Target {
get {
object ob = ViewState ["Target"];
- if (ob != null) return (string) ob;
- return "";
+ if (ob != null)
+ return (string) ob;
+ return String.Empty;
}
set {
ViewState ["Target"] = value;
public virtual string Text {
get {
object ob = ViewState ["Text"];
- if (ob != null) return (string) ob;
- return "";
+ if (ob != null)
+ return (string) ob;
+ return String.Empty;
}
set {
ViewState ["Text"] = value;
}
}
- public override void InitializeCell (DataControlFieldCell cell,
- DataControlCellType cellType, DataControlRowState rowState, int rowIndex)
+ public override void InitializeCell (DataControlFieldCell cell,DataControlCellType cellType, DataControlRowState rowState, int rowIndex)
{
- base.InitializeCell (cell, cellType, rowState, rowIndex);\r
- if (cellType == DataControlCellType.DataCell) {\r
- HyperLink link = new HyperLink ();\r
- bool bind = false;\r
-\r
- if (Target.Length > 0)\r
- link.Target = Target;\r
-\r
- if (DataTextField.Length > 0)\r
- bind = true;\r
- else\r
- link.Text = Text;\r
-\r
- string [] fields = DataNavigateUrlFields;\r
- if (fields.Length > 0)\r
- bind = true;\r
- else\r
- link.NavigateUrl = NavigateUrl;\r
-\r
- if (bind && cellType == DataControlCellType.DataCell && (rowState & DataControlRowState.Insert) == 0)\r
- cell.DataBinding += new EventHandler (OnDataBindField);\r
-\r
- link.ControlStyle.CopyFrom (ControlStyle);\r
-\r
- cell.Controls.Add (link);\r
+ base.InitializeCell (cell, cellType, rowState, rowIndex);
+ if (cellType == DataControlCellType.DataCell) {
+ HyperLink link = new HyperLink ();
+ bool bind = false;
+
+ if (Target.Length > 0)
+ link.Target = Target;
+
+ if (DataTextField.Length > 0)
+ bind = true;
+ else
+ link.Text = Text;
+
+ string [] fields = DataNavigateUrlFields;
+ if (fields.Length > 0)
+ bind = true;
+ else
+ link.NavigateUrl = NavigateUrl;
+
+ if (bind && cellType == DataControlCellType.DataCell && (rowState & DataControlRowState.Insert) == 0)
+ cell.DataBinding += new EventHandler (OnDataBindField);
+
+ link.ControlStyle.CopyFrom (ControlStyle);
+
+ cell.Controls.Add (link);
}
}
protected virtual string FormatDataNavigateUrlValue (object[] dataUrlValues)
{
if (dataUrlValues == null || dataUrlValues.Length == 0)
- return "";
+ return String.Empty;
else if (DataNavigateUrlFormatString.Length > 0)
return string.Format (DataNavigateUrlFormatString, dataUrlValues);
else
if (DataTextFormatString.Length > 0)
return string.Format (DataTextFormatString, dataTextValue);
else if (dataTextValue == null)
- return "";
+ return String.Empty;
else
return dataTextValue.ToString ();
}
PropertyDescriptorCollection props = TypeDescriptor.GetProperties (item);
if (DataTextField.Length > 0) {
- textProperty = props [DataTextField];
+ textProperty = props.Find (DataTextField, true);
if (textProperty == null)
- new InvalidOperationException ("Property '" + DataTextField + "' not found in object of type " + item.GetType());
+ throw new InvalidOperationException ("Property '" + DataTextField + "' not found in object of type " + item.GetType());
}
string[] urlFields = DataNavigateUrlFields;
if (urlFields.Length > 0) {
urlProperties = new PropertyDescriptor [urlFields.Length];
for (int n=0; n<urlFields.Length; n++) {
- PropertyDescriptor prop = props [urlFields [n]];
+ PropertyDescriptor prop = props.Find (urlFields [n], true);
if (prop == null)
- new InvalidOperationException ("Property '" + urlFields [n] + "' not found in object of type " + item.GetType());
+ throw new InvalidOperationException ("Property '" + urlFields [n] + "' not found in object of type " + item.GetType());
urlProperties [n] = prop;
}
}
}
}
}
-#endif
+