Accueil > > > TOOLS HTML
TOOLS HTML
Information sur la source
Description
C'est un petit exemple d'utilisation d'objet en ASP. Le but étant de se simplifier la vie en ayant des objets formulaires prêts à l'emploi et de pouvoir facilement changer l'aspect d'un site sans se retaper tout le html. Le zip comprend un fichier test qui utilise ces objets Happy coding !
Source
- <%
- 'Toutes licences accordées à zappy
-
- class typeItem
- public key
- public caption
- end class
-
- class optiComboBox
- public SelectName
-
- private myItem()
- private ItemCount
- public activeKey
-
-
- public function AddItem(key, caption)
- redim preserve myItem(ItemCount)
- set myItem(ItemCount) = new typeItem
- myItem(ItemCount).key = key
- myItem(ItemCount).caption = caption
- ItemCount = ItemCount + 1
- end function
-
- public sub Clear()
- erase MyItem
- ItemCount = 0
- end sub
-
- public function getStringHTML()
- dim strBuffer, i
- if ItemCount > 0 then
- for i=0 to (ItemCount - 1) step 1
- strBuffer = strBuffer & "<option value=" & chr(34) & myItem(i).key & chr(34)
- if myItem(i).key = activeKey then
- strBuffer = strBuffer & " selected"
- end if
- strBuffer = strBuffer & ">" & myItem(i).caption & "</option>" & VbCrLf
- next
- strBuffer = "<select name=" & chr(34) & SelectName & chr(34) & ">" & VbCrLf & strBuffer & "</select>"
- end if
- getStringHTML = strBuffer
- end function
- end class
-
- class optiDateComboBox
- public intMinYear
- public intMaxYear
- public dtValue
- public strName
-
- private sub class_initialize()
- intMinYear = year(now()) - 100
- intMaxYear = year(now()) + 1
- end sub
-
- public function SetNewValue(strDay, strMonth, strYear)
- dim strBuffer
- strBuffer = strDay & "/" & strMonth & "/" & strYear
- if isdate(strbuffer) then
- dtValue = CDate(strBuffer)
- SetNewValue = true
- else
- SetNewValue = false
- end if
- end function
-
- public function getStringHTML()
- Dim strBuffer
- Dim i
-
- If intMinYear > intMaxYear Then Exit Function
- if not isdate(dtValue) then dtValue = #01/01/1950#
- 'Les jours
- strBuffer = "<select name=" & Chr(34) & strName & "jj" & Chr(34) & ">" & VbCrLf
- For i = 1 To 31 Step 1
- strBuffer = strBuffer & "<option value=" & Chr(34) & CStr(i) & Chr(34)
- If CInt(Day(dtValue)) = i Then strBuffer = strBuffer & " selected"
- strBuffer = strBuffer & ">" & CStringNombre(i,2) & "</option>" & VbCrLf
- Next
- strBuffer = strBuffer & "</select>" & VbCrLf & "/" & VbCrLf
-
- 'Les mois
- strBuffer = strBuffer & "<select name=" & Chr(34) & strName & "mm" & Chr(34) & ">" & VbCrLf
- For i = 1 To 12 Step 1
- strBuffer = strBuffer & "<option value=" & Chr(34) & CStr(i) & Chr(34)
- If CInt(Month(dtValue)) = i Then strBuffer = strBuffer & " selected"
- strBuffer = strBuffer & ">" & CStringNombre(i,2) & "</option>" & VbCrLf
- Next
- strBuffer = strBuffer & "</select>" & VbCrLf & "/" & VbCrLf
-
-
- 'Les annees
- strBuffer = strBuffer & "<select name=" & Chr(34) & strName & "aa" & Chr(34) & ">" & VbCrLf
- For i = intMinYear To intMaxYear Step 1
- strBuffer = strBuffer & "<option value=" & Chr(34) & CStr(i) & Chr(34)
- If CInt(Year(dtValue)) = i Then strBuffer = strBuffer & " selected"
- strBuffer = strBuffer & ">" & CStringNombre(i,4) & "</option>" & VbCrLf
- Next
- strBuffer = strBuffer & "</select>" & VbCrLf
-
- getStringHTML = strBuffer
- end function
- end class
-
- class optiRadioBox
- public RadioName
- private myItem()
- private ItemCount
- public activeKey
-
-
- public function AddItem(key, caption)
- redim preserve myItem(ItemCount)
- set myItem(ItemCount) = new typeItem
- myItem(ItemCount).key = key
- myItem(ItemCount).caption = caption
- ItemCount = ItemCount + 1
- end function
-
- public sub Clear()
- erase MyItem
- ItemCount = 0
- end sub
-
- public property get CountItem()
- CountItem = ItemCount
- end property
-
- public function GetStringHTML(itemKey)
- for i = 0 to ItemCount - 1 step 1
- if myItem(i).key = itemKey then
- GetStringHTML = GetStringHTMLItem(i)
- exit for
- end if
- next
- end function
- public function GetStringHTMLItem(indexItem)
- dim strBuffer
- strBuffer = "<input type=""radio"" name=""" & RadioName & """ value=""" & cstr(myItem(indexItem).key) & """"
- if myItem(indexItem).key = activeKey then
- strBuffer = strBuffer & " CHECKED"
- end if
- GetStringHTMLItem = strBuffer & ">" & myItem(indexItem).caption
- end function
- end class
-
-
- public function CStringNombre(value, nbrChiffre)
- if len(cstr(value)) < nbrChiffre then
- CStringNombre = string(nbrChiffre - len(cstr(value)),"0") & cstr(value)
- else
- CStringNombre = cstr(value)
- end if
- end function
-
- function opt_processArray(inArray, inStringRow)
-
- returnString = ""
- bufferString = ""
- on error resume next
-
- nbrRow = ubound(inArray) - lbound(inArray)
- nbrField = ubound(inArray, 2) - lbound(inArray, 2)
- if err.number <> 0 then exit function
-
- on error goto 0
-
- for i = lbound(inArray) to ubound(inArray) step 1
- bufferString = inStringRow
- for n=lbound(inArray,2) to ubound(inArray,2) step 1
- bufferString = replace(bufferString, "{" & CStr(n) & "}",CStr(inArray(i,n)))
- next
- returnString = returnString & bufferString 'Retour charriot dans la string passée en argument !!
- next
-
- opt_processArray = returnString
- end function
- %>
<%
'Toutes licences accordées à zappy
class typeItem
public key
public caption
end class
class optiComboBox
public SelectName
private myItem()
private ItemCount
public activeKey
public function AddItem(key, caption)
redim preserve myItem(ItemCount)
set myItem(ItemCount) = new typeItem
myItem(ItemCount).key = key
myItem(ItemCount).caption = caption
ItemCount = ItemCount + 1
end function
public sub Clear()
erase MyItem
ItemCount = 0
end sub
public function getStringHTML()
dim strBuffer, i
if ItemCount > 0 then
for i=0 to (ItemCount - 1) step 1
strBuffer = strBuffer & "<option value=" & chr(34) & myItem(i).key & chr(34)
if myItem(i).key = activeKey then
strBuffer = strBuffer & " selected"
end if
strBuffer = strBuffer & ">" & myItem(i).caption & "</option>" & VbCrLf
next
strBuffer = "<select name=" & chr(34) & SelectName & chr(34) & ">" & VbCrLf & strBuffer & "</select>"
end if
getStringHTML = strBuffer
end function
end class
class optiDateComboBox
public intMinYear
public intMaxYear
public dtValue
public strName
private sub class_initialize()
intMinYear = year(now()) - 100
intMaxYear = year(now()) + 1
end sub
public function SetNewValue(strDay, strMonth, strYear)
dim strBuffer
strBuffer = strDay & "/" & strMonth & "/" & strYear
if isdate(strbuffer) then
dtValue = CDate(strBuffer)
SetNewValue = true
else
SetNewValue = false
end if
end function
public function getStringHTML()
Dim strBuffer
Dim i
If intMinYear > intMaxYear Then Exit Function
if not isdate(dtValue) then dtValue = #01/01/1950#
'Les jours
strBuffer = "<select name=" & Chr(34) & strName & "jj" & Chr(34) & ">" & VbCrLf
For i = 1 To 31 Step 1
strBuffer = strBuffer & "<option value=" & Chr(34) & CStr(i) & Chr(34)
If CInt(Day(dtValue)) = i Then strBuffer = strBuffer & " selected"
strBuffer = strBuffer & ">" & CStringNombre(i,2) & "</option>" & VbCrLf
Next
strBuffer = strBuffer & "</select>" & VbCrLf & "/" & VbCrLf
'Les mois
strBuffer = strBuffer & "<select name=" & Chr(34) & strName & "mm" & Chr(34) & ">" & VbCrLf
For i = 1 To 12 Step 1
strBuffer = strBuffer & "<option value=" & Chr(34) & CStr(i) & Chr(34)
If CInt(Month(dtValue)) = i Then strBuffer = strBuffer & " selected"
strBuffer = strBuffer & ">" & CStringNombre(i,2) & "</option>" & VbCrLf
Next
strBuffer = strBuffer & "</select>" & VbCrLf & "/" & VbCrLf
'Les annees
strBuffer = strBuffer & "<select name=" & Chr(34) & strName & "aa" & Chr(34) & ">" & VbCrLf
For i = intMinYear To intMaxYear Step 1
strBuffer = strBuffer & "<option value=" & Chr(34) & CStr(i) & Chr(34)
If CInt(Year(dtValue)) = i Then strBuffer = strBuffer & " selected"
strBuffer = strBuffer & ">" & CStringNombre(i,4) & "</option>" & VbCrLf
Next
strBuffer = strBuffer & "</select>" & VbCrLf
getStringHTML = strBuffer
end function
end class
class optiRadioBox
public RadioName
private myItem()
private ItemCount
public activeKey
public function AddItem(key, caption)
redim preserve myItem(ItemCount)
set myItem(ItemCount) = new typeItem
myItem(ItemCount).key = key
myItem(ItemCount).caption = caption
ItemCount = ItemCount + 1
end function
public sub Clear()
erase MyItem
ItemCount = 0
end sub
public property get CountItem()
CountItem = ItemCount
end property
public function GetStringHTML(itemKey)
for i = 0 to ItemCount - 1 step 1
if myItem(i).key = itemKey then
GetStringHTML = GetStringHTMLItem(i)
exit for
end if
next
end function
public function GetStringHTMLItem(indexItem)
dim strBuffer
strBuffer = "<input type=""radio"" name=""" & RadioName & """ value=""" & cstr(myItem(indexItem).key) & """"
if myItem(indexItem).key = activeKey then
strBuffer = strBuffer & " CHECKED"
end if
GetStringHTMLItem = strBuffer & ">" & myItem(indexItem).caption
end function
end class
public function CStringNombre(value, nbrChiffre)
if len(cstr(value)) < nbrChiffre then
CStringNombre = string(nbrChiffre - len(cstr(value)),"0") & cstr(value)
else
CStringNombre = cstr(value)
end if
end function
function opt_processArray(inArray, inStringRow)
returnString = ""
bufferString = ""
on error resume next
nbrRow = ubound(inArray) - lbound(inArray)
nbrField = ubound(inArray, 2) - lbound(inArray, 2)
if err.number <> 0 then exit function
on error goto 0
for i = lbound(inArray) to ubound(inArray) step 1
bufferString = inStringRow
for n=lbound(inArray,2) to ubound(inArray,2) step 1
bufferString = replace(bufferString, "{" & CStr(n) & "}",CStr(inArray(i,n)))
next
returnString = returnString & bufferString 'Retour charriot dans la string passée en argument !!
next
opt_processArray = returnString
end function
%>
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
L'INTERFACE NATURELLE DE WINDOWS PHONE 7 SERIESL'INTERFACE NATURELLE DE WINDOWS PHONE 7 SERIES par odewit
La tendance est aux interfaces naturelles (NUI), et le keynote de Bill Buxton au MIX l'a bien souligné.
La charte graphique et ergonomique de Windows Phone 7 a donc été entièrement repensée en vue d'obtenir un maximum d'efficacité sur ce point. En re...
Cliquez pour lire la suite de l'article par odewit COMMENT MAPPER UNE VUE SQL SUR UNE COLLECTION DE COMPLEX TYPE?COMMENT MAPPER UNE VUE SQL SUR UNE COLLECTION DE COMPLEX TYPE? par Matthieu MEZIL
Avec EF, les vues doivent être mappées sur des entity types. Le problème c'est que les entity types doivent avoir une clé. Avec EF, nous avons les complex type qui n'ont pas de clé mais les vues ne peuvent pas être mappées dessus. Avec EF4, il est possibl...
Cliquez pour lire la suite de l'article par Matthieu MEZIL [WF4] UN BINDING ACTIVITY/ACTIVITYDESIGNER QUI PASSE MAL?[WF4] UN BINDING ACTIVITY/ACTIVITYDESIGNER QUI PASSE MAL? par JeremyJeanson
Certain d'entre vous on peut être vécu cette situation embarrassante après quelques temps passer avec WF4 : Au début avec mon " ActivityDesigner" , tout allait bien. Et puis un jour j'ai au des problèmes de " Binding" . Alors nous sommes allé sur le site ...
Cliquez pour lire la suite de l'article par JeremyJeanson
Forum
UTILISATEURUTILISATEUR par zaydounhlel
Cliquez pour lire la suite par zaydounhlel RE : VIRUSRE : VIRUS par ghuysmans99
Cliquez pour lire la suite par ghuysmans99
Logiciels
Academy System (10.9.4.0)ACADEMY SYSTEM (10.9.4.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Xilisoft Convertisseur Vidéo Ultimate (5.1.39.0305)XILISOFT CONVERTISSEUR VIDéO ULTIMATE (5.1.39.0305)Xilisoft Convertisseur Vidéo Ultimate est un outil puissant de conversion vidéo, facile à utilise... Cliquez pour télécharger Xilisoft Convertisseur Vidéo Ultimate Xilisoft DVD Ripper Ultimate (5.0.64.0304)XILISOFT DVD RIPPER ULTIMATE (5.0.64.0304)Xilisoft DVD Ripper Ultimate est un logiciel excellent pour copier et convertir DVD vers presque ... Cliquez pour télécharger Xilisoft DVD Ripper Ultimate Rigs of Rods (63.3)RIGS OF RODS (63.3)c'est un jeu de multi-simulation camions,autobus voitures, avions, bateaux, hélicoptère avec défo... Cliquez pour télécharger Rigs of Rods
|