Das ist der Code meines Controls:
Imports System.Web.UI
Imports System.Web.UI.HtmlControls
Public Class HiddenControl
Inherits Control
Implements INamingContainer
Implements IPostBackEventHandler
Public Property Value() As String
Get
Dim Ctrl As HtmlInputHidden = Controls(0)
Me.EnsureChildControls()
Return Ctrl.Value
End Get
Set(ByVal Value As String)
Dim Ctrl As HtmlInputHidden = Controls(0)
Me.EnsureChildControls()
Ctrl.Value = Value
End Set
End Property
Public Property ImpriValue() As String
Get
Dim Ctrl As HtmlInputHidden = Controls(1)
Me.EnsureChildControls()
Return Ctrl.Value
End Get
Set(ByVal Value As String)
Dim Ctrl As HtmlInputHidden = Controls(1)
Me.EnsureChildControls()
Ctrl.Value = Value
End Set
End Property
Public Event OnClick(ByVal Sender As Object, ByVal E As EventArgs)
Public Sub RaisePostBackEvent(ByVal EventArgument As String) Implements
IPostBackEventHandler.RaisePostBackEvent
RaiseEvent OnClick(Me, New System.EventArgs())
End Sub
Protected Overrides Sub CreateChildControls()
Dim HidBox As New HtmlInputHidden()
HidBox.ID = "HidBox"
HidBox.EnableViewState = True
Me.Controls.Add(HidBox)
Dim ImpriBox As New HtmlInputHidden()
ImpriBox.ID = "ImpriBox"
ImpriBox.EnableViewState = True
Me.Controls.Add(ImpriBox)
Dim str As String
str = "<script>"
str = str & " function postback(tipo) {"
str = str & " if (tipo == ""imprimir"") {"
str = str & " var IdUbicacion = document.getElementById('" & Me.ID &
"_" & ImpriBox.ID & "').value; "
str = str & " window.open(""PDFExtintores.aspx?IdUbicacion="" +
IdUbicacion, ""PDF"" + IdUbicacion, ""toolbar=no, location=no, directories=no,
resizable=yes, status=no, scrollbars=yes, copyhistory=no, left=10, top=10"");"
str = str & " }"
str = str & " else {"
str = str & "document.getElementById('" & Me.ID & "_" & HidBox.ID &
"').value = tipo; "
str = str & Page.GetPostBackEventReference(Me, "") & ";"
str = str & " }"
str = str & " }"
str = str & " </script>"
Me.Controls.Add(New LiteralControl(str))
Me.EnableViewState = True
End Sub
End Class
Dieses Control f�ge ich einfach im Html Code ein und im PageLoad m�chte ich
einen Wert �bergeben:
HiddenControl1.ImpriValue = IdUbicacion
Dann bekomme ich in Linie12 eine System.ArgumentOutOfRangeException:
L�nea 10: Public Property Value() As String
L�nea 11: Get
L�nea 12: Dim Ctrl As HtmlInputHidden = Controls(0)
L�nea 13: Me.EnsureChildControls()
L�nea 14: Return Ctrl.Value
Gru�,
Martin
> Hallo,
>
> >
> > ich habe so ein �hnliches Problem: Ich habe ein Control geschrieben und
> > m�chte ihm im PageLoad einen Parameter �bergeben, bekomme aber
> > einen Error, weil
> > mein Control die CreateChildrenControls() Methode noch nicht
> > durchlaufen hat
> > und die Untercontrols noch nicht initialisiert wurden.
> > Geht das auch mit einem Databind()? Wie mach ich das?
> >
>
> wie sieht Dein Code jetzt aus?
> Welche Fehlermeldung bekommst Du genau? (u. Parser oder Compiler?)
>
> Gruss
>
> Alex
>
> _______________________________________________
> Asp.net mailing list
> [EMAIL PROTECTED]
> http://www.glengamoi.com/mailman/listinfo/asp.net
>
--
NEU F�R ALLE - GMX MediaCenter - f�r Fotos, Musik, Dateien...
Fotoalbum, File Sharing, MMS, Multimedia-Gru�, GMX FotoService
Jetzt kostenlos anmelden unter http://www.gmx.net
+++ GMX - die erste Adresse f�r Mail, Message, More! +++
_______________________________________________
Asp.net mailing list
[EMAIL PROTECTED]
http://www.glengamoi.com/mailman/listinfo/asp.net