Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
microsoft.public.dotnet.framework.aspnet.webcontrols
I Builded a WebControl, but it reinitializes in every POST, How can I avoid this?
Andrés Giraldo
1/15/2003 6:19:00 PM
Hi!
I builded a webcontrol to simulate the VB6 DataControl, it works with a
dataset and worked fine, until I put the graphical interface... when a
user clicks on Next, Previous, First or Last button, it makes the
resposition as I expected, but it does a POST too, so the object it's
initialized again and every data on it it's lost...
I tried to put the control in the session object, and it works if I
call the reposition methods from the webform working with the object
stored in the session, but if I use the control button's it fails
again, even if I assign it the value of the object defined in the
session at the end of the postback event...
Any idea of how can I solve this?
Thanks!
-----------------------------------------------------
Here's my class code:
Imports System
Imports System.ComponentModel
Imports System.Data.OleDb
Imports System.Web.UI
Imports System.Web.UI.WebControls
Public Class MyRs
Inherits WebControls.WebControl
Implements INamingContainer
.. private attributes ...
Dim WithEvents btnPrevious As New Button()
Dim WithEvents btnFirst As New Button()
Dim WithEvents btnNext As New Button()
Dim WithEvents btnLast As New Button()
Dim WithEvents txtIndicator As New TextBox()
.. public properties ...
.. methods ...
Public Sub PreviousRecord()
End Sub
Private Sub btnPrevious_Clicked(ByVal sender As Object, ByVal e As
EventArgs)
PreviousRecord()
End Sub
.. other reposition methods ...
Protected Overrides Sub CreateChildControls()
With btnPrevious
.CausesValidation = False
.Font.Bold = True
.ID = "btnPrevious"
.TabIndex = 0
.Text = "<"
.ToolTip = "Go To The Previous Record"
AddHandler .Click, AddressOf btnPrevious_Clicked
End With
Controls.Add(btnPrevious)
.. creation of the other buttons ..
End Sub
End Class
-----------------------------------------------------
Here's my webform code:
Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents MyRS1 As MyRS
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents OleDbConnection1 As
System.Data.OleDb.OleDbConnection
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If (Not IsPostBack) Then
Session("MyRS1") = MyRS1
With Session("MyRS1")
.Conexion = OleDbConnection1
.AbrirTabla("SELECT * FROM Test")
End With
End If
MyRS1 = Session("MyRS1") 'Even If I assign the value of the
object in session, it didn't works...
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
With Session("MyRS1")
.FirstRecord() 'It Works, because I'm working with the
object defined in the session
End With
End Sub
End Class
*** Sent via Developersdex
http://www.develop...
***
Don't just participate in USENET...get rewarded for it!
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
I Builded a WebControl, but it reinitializes in every POST, How can I avoid this?
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password