Archiv der Kategorie ASP.NET

string.replace with DataBinder.Eval in ASP.NET

string.replace mit DataBinder.Eval in ASP.NET 

 

Um die Funktion replace im Databinder zu nutzen kann man folgende Vorgehensweise wählen: 

Ohne Replace: 

<a href=”page.aspx?id=<%#DataBinder.Eval(Container.DataItem, ” fileID “)%>“>  LINKTEXT                                                                                                                                                                             </a> 

Mit Replace: 

<a href=”page.aspx?id=<%#DataBinder.Eval(Container.DataItem, ” fileID “).replace(”textToFind”,”ReplaceWithThis”)%>“> LINKTEXT                                                                                                                                                                             </a> 

 

To use string.replace in databinder use the following example: 

Without Replace: 

<a href=”page.aspx?id=<%#DataBinder.Eval(Container.DataItem, “fileID”)%>“>  LINKTEXT                                                                                                                                                                                                                                                                                                                                                          </a> 

With Replace: 

<a href=”page.aspx?id=<%#DataBinder.Eval(Container.DataItem, ” fileID “).replace(”textToFind”,”ReplaceWithThis”)%>“> LINKTEXT                                                                                                                                                                             </a> 

 

Was that helpfull? Please link my Blog.

ASP.NET GRIDVIEW: Einzelne Zellen verändern

Inhalt: Den Inhalt einer Zelle eines GridViews auslesen und / oder updaten 

Content: Getting a Value or editing content of a cell within a GridView 

Folgendes selbsterklärendes Beispiel:

 

Dim sqlStr As String = “SELECT * FROM Customers”       

Dim dt As New DataTable 

dt = …  

GridView1.DataSource = dt

GridView1.DataBind() 

GridView1.Rows(1).Cells(1).Text = “my static Text”  

Bei Fragen stehe ich per eMail zur Verfügung.

 

VB.NET: Function Wordwrap in ASP.NET

VB.NET:  Function Wordwrap in ASP.NET 

 

 

Viele kennen vielleicht die PHP-Funktion  „wordwrap“. Stand heute gibt es eine solche Funktion nicht im .NET Framework – Zumindest entzieht sich das meiner Kenntnis. 

Gerade im Bereich HTML-Layout ist es problematisch Daten aus <TEXTAREA> Feldern vernünftig zu formatieren.  

 

Grund genug eine Funktion wordwrap selbst zu bauen: 

 

 

 

Public Function wordrap(ByVal currentText As String, ByVal_ maxCharsPerLine As Integer) As String 

    Dim returnString As String = “” 

    Dim rx As New Regex(“(\S{” & maxCharsPerLine.toString & “})”,_ RegexOptions.IgnoreCase) 

    returnString = rx.Replace(currentText, “$1 “) 

     Return returnString 

End Function 

 

 

 

War diese Information hilfreich? Dann würde ich mich über eine Verlinkung freuen. 

Was this Information helpfull? I’d be very pleased if you link my page. 

Attribute border outdated

Warning Validation (XHTML 1.0 Transitional): Attribute ‘border’ is considered outdated. A newer construct is recommended.

In Visual Studio 2005 erscheint folgende Warnung:
“Warning Validation (XHTML 1.0 Transitional): Attribute ‘border’ is considered outdated. A newer construct is recommended.”
In meinem Beispiel hatte ich im Image-Tag folgendes Konstrukt:

<img height=”1″ alt=”" src=”images/black_dot.gif” mce_src=”images/black_dot.gif” width=”100%” border=”0″ />

Nach der neuen Microsoft Empfehlung macht man das jetzt so:


<img height=”1″ alt=”" src=”images/black_dot.gif” mce_src=”images/black_dot.gif” width=”100%” style=”border:none;” />

um einen Rahmen anzuzeigen so:

<img height=”1″ alt=”" src=”images/black_dot.gif” mce_src=”images/black_dot.gif” width=”100%” style=”border:7px;” />


Folge: Keine Warnmeldung mehr.

XHTML 1.0 Transitional

Elemente „ALT“

Elemente „Neu“

 

 

<menu />

Use another list type.

<u />

Use CSS property “text-decoration” and set its value to “underline”.

<s />

Use CSS property “text-decoration” and set its value to “line-through”.

<strike />

Use CSS property “text-decoration” and set its value to “line-through”.

<basefont />

Use CSS styling and set the “font-family” property to desired font.

<font />

Use CSS styling to set the property of the element, such as a DIV or SPAN.The CSS properties include:

  • color
  • font-family
  • font-size
  • text-decoration
  • text-align
  • text-indent
  • text-transform
  • font-weight

<applet />

Use the <object /> tag

<isindex /> 

Use the <input /> tag

<i />

Use the <em /> tag

<b />

Use the <strong /> tag

 

 

Elements / Attributes

Newer Constructs

 

 

Iframe

 

name

Use the ID attribute

align

Use the CSS property “text-align”

body

 

background

Use the CSS property “background-image” or “background”.

bgcolor

Use the CSS property “background-color” or “background”.

text

Use the CSS property “color” for the “body” style

link

Use the CSS section “a:link” and set the property “color”.

vlink

Use the CSS section “a:visited” and set the property “color”.

alink

“a:hover” and set the property “color”.

div / p / h1…h6

 

align

Use the CSS property “text-align”.

ul / ol / li

 

type  

Use the CSS property “list-style-type” or “list-style”.

compact      

This attribute has been removed from the HTML DOM 1.0

hr

 

align  

Use the CSS property “text-align”.

noshade      

Use the CSS property “color”.

size   

Use the CSS property “height”.

width 

Use the CSS property “width”.

pre

 

width 

Use the CSS property “width”.

name

Use the attribute “id”.

br

 

clear 

Use the CSS property “clear”.

object

 

align

Use the CSS property “vertical-align” and “text-align” in the parent tag

border

Use the CSS property “border”.

hspace

Use the CSS property “padding”.

vspace

Use the CSS property “padding”.

img

 

name

Use the attribute “id”.

align

Use the CSS property “vertical-align” and “text-align” in the parent tag

border

Use the CSS property “border”.

hspace

Use the CSS property “padding”.

vspace

Use the CSS property “padding”.

map

 

name

Use the attribute “id”.

input

 

align

Use the CSS property “vertical-align” and “text-align”

legend

 

name

Use the attribute “id”.

table

 

align

Set table’s CSS properties left-margin and right-margin at “auto” for centering, or right-margin to 0 for right alignment, or the left-margin to 0 for left alignment.

bgcolor

Use the CSS property “background-color”.

tr

 

bgcolor       

Use the CSS property “background-color”.

td, th

 

nowrap

Use the CSS property “word-wrap”.

bgcolor

Use the CSS property “background-color”.

width 

Use the CSS property “width”.

height

Use the CSS property “height”.

 

Attribute bgcolor is considered outdated

Warning 1 Validation (XHTML 1.0 Transitional): Attribute ‘bgcolor’ is considered outdated. A newer construct is recommended.  

In Visual Studio erscheint folgende Warnung:
“Warning 1 Validation (XHTML 1.0 Transitional): Attribute ‘bgcolor’ is considered outdated. A newer construct is recommended.”

Im Body-Tag hatte ich folgendes Konstrukt:

                <body bgcolor=”#FFFFFF”>

Dieses kann man mit diesem String ersetzen:

                  <body style=”background-color:#FFFFFF”>

Folge: Die Warnmeldung verschwindet.

|