Usare findcontrol all'interno di una dll

mercoledì 24 novembre 2004 - 19.38

s_dimaio Profilo | Junior Member

Sto' registrando una dll con all'interno il comando [b]findcontrol[/b].

Solo mi da l'errore: "findcontrol is not declared".

Ho importato i namespace:

Imports System
Imports System.Math
Imports System.Xml
Imports System.Web.UI
Imports System.Web.UI.WebControls

Manca quello giusto o è un altro tipo di problema?

Ciao e grazie

LudovicoVan Profilo | Junior Member

FindControl() è (fra l'altro) un metodo di Control... Sei sicuro di avere un'istanza di Control? Vuoi provare a mostrare il codice in questione?

Ciao. -LV

s_dimaio Profilo | Junior Member

Ecco il codice:

Public Class InvClass

Private Sub WriteTmpXml (PathUserXml As String, MyPlace As ControlCollection)

Dim myXmlDocument As New XmlDocument()
myXmlDocument.Load (PathUserXml)
Dim root As XmlElement = myXmlDocument.DocumentElement
Dim CashTot As Integer = root.attributes("cashtot").value
Dim CashSpes As Integer = 0

For i As Integer = 0 To MyPlace.count - 1

If TypeOf MyPlace(i) Is Label Then

Dim prefix As string = CType(MyPlace(i), Label).id
Dim ctrlupg As TextBox = FindControl(prefix & "_incremento")
Dim ctrltime As TextBox = FindControl(prefix & "_tempo")
Dim ctrlcash As TextBox = FindControl(prefix & "_costo")

If ctrlupg.text <> "" And ctrltime.text <> "" Then

Dim nodename As string = prefix
Dim updnode As XmlNodeList = root.GetElementsByTagName(nodename)

updnode.itemof(0).InnerText = ctrlupg.Text
updnode.itemof(0).attributes("tempo").value = ctrltime.Text
updnode.itemof(0).attributes("costo").value = ctrlcash.Text

End If

CashSpes += ctrlcash.Text

End If

Next

If CashSpes <= CashTot Then
myXmlDocument.Save(PathUserXml)
'Response.Write("SALVATAGGIO COMPLETATO!!!!! - HAI SPESO " & CashSpes)
Else
'Response.Write("HAI SPESO TROPPO!!!!!")
End If

End Sub

End Class

s_dimaio Profilo | Junior Member

Sulla guida al framework ho trovato:

Private Sub Button1_Click(sender As Object, MyEventArgs As EventArgs)
' Find control on page.
Dim myControl1 As Control = FindControl("TextBox2")
If (Not myControl1 Is Nothing)
' Get control's parent.
Dim myControl2 As Control = myControl1.Parent
Response.Write("Parent of the text box is : " & myControl2.ID)
Else
Response.Write("Control not found.....")
End If
End Sub


inoltre lo stesso script fino a quando lo usavo all'interno del code-behind funzionava tranquillamente. E' quando ho deciso di creare una dll che mi restituisce qull'errore.

Hai qualche idea?

Brainkiller Profilo | Guru

>Sto' registrando una dll con all'interno il comando

Stai registrando o stai compilando una DLL ?
Le DLL del Framework non si registrano più come avveniva con le COM based.

ciao
david

s_dimaio Profilo | Junior Member

Si scusa, volevo dire compilando. Comunque grazie, poi ho risolto
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5