begin process at 2012 02 05 01:47:56
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Formulaires

 > TOOLS HTML

TOOLS HTML


 Information sur la source

Note :
9,5 / 10 - par 2 personnes
9,50 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Formulaires Niveau :Débutant Date de création :11/12/2002 Date de mise à jour :11/12/2002 10:39:04 Vu / téléchargé :7 511 / 292

Auteur : zappy

Ecrire un message privé
Site perso
Ce membre participe au partage de revenus publicitaires
Commentaire sur cette source (1)
Ajouter un commentaire et/ou une note


 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
%>


 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip


 Sources de la même categorie

Source .NET (Dotnet) COMMENT FORMATER LE NOMBRE DE CARACTÈRES D'UN COLONNE DANS U... par PascalCmoa
Source avec une capture Source .NET (Dotnet) AJOUTER UNE IMAGE À UN BOUTON par PascalCmoa
Source avec Zip Source avec une capture Source .NET (Dotnet) UPLOADER PLUSIEURS FICHIERS AVEC BARRE DE PROGRESSION AJAX par clemox
Source avec Zip Source .NET (Dotnet) DATAGRID AVEC RECHERCHE ALPHABÉTIQUE par gatita_dev
Source avec Zip Source avec une capture Source .NET (Dotnet) IMAGE ANTI-BOT ET VALIDATION DE FORMULAIRES par badrbadr

Commentaires et avis

Commentaire de peucher le 21/10/2003 15:32:08

Juste une petite question, connaitrais-tu une programmation qui permettrait derendre la touche ESC active dans une page asp ou aspx pour fermer une application.exe

 Ajouter un commentaire




Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 2,761 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales