|
-
Mar 10th, 2005, 03:32 AM
#1
Thread Starter
Hyperactive Member
Problem on inheriting from web form
Hi everybody,
I have made a web form class which I want to use as a base class for all data entry web forms. Following is the structure of the web form:
VB Code:
Public Class WFrmEnt
Inherits System.Web.UI.Page
Protected WithEvents nLast As System.Web.UI.WebControls.ImageButton
Protected WithEvents nNext As System.Web.UI.WebControls.ImageButton
Protected WithEvents nPrev As System.Web.UI.WebControls.ImageButton
Protected WithEvents nCancel As System.Web.UI.WebControls.Button
Protected WithEvents nSave As System.Web.UI.WebControls.Button
Protected WithEvents nMessage As System.Web.UI.WebControls.Label
Protected WithEvents nDelete As System.Web.UI.WebControls.Button
Protected WithEvents nModify As System.Web.UI.WebControls.Button
Protected WithEvents nAdd As System.Web.UI.WebControls.Button
Protected WithEvents nPrint As System.Web.UI.WebControls.Button
Protected WithEvents nFilter As System.Web.UI.WebControls.Button
Protected WithEvents nFirst As System.Web.UI.WebControls.ImageButton
Protected WithEvents nRemoveFilter As System.Web.UI.WebControls.Button
Private Sub nFirst_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles
nFirst.Click
Navigate(CNavAction.First)
End Sub
Private Sub nPrev_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles nPrev.Click
Navigate(CNavAction.Prev)
End Sub
Private Sub nNext_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles nNext.Click
Navigate(CNavAction.Next)
End Sub
Private Sub nLast_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles nLast.Click
Navigate(CNavAction.Last)
End Sub
Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
MyBase.Render(writer)
End Sub
End Class
For making a data entry web form, I first add a new web form and place all the required controls on it including nAdd, nModify, nDelete, nFirst, nNext, nPrev, etc. After that, in the code behind page, I change the clause "Inherits System.Web.UI.Page" to "Inherits WFrmEnt". Everything works fine.
But my problem is that when I go to the designer screen of the web form, it inserts the declarations for the variables of the controls that are inherited from the base web form. It inserts the following code:
VB Code:
Protected WithEvents nLast As System.Web.UI.WebControls.ImageButton
Protected WithEvents nNext As System.Web.UI.WebControls.ImageButton
Protected WithEvents nPrev As System.Web.UI.WebControls.ImageButton
Protected WithEvents nCancel As System.Web.UI.WebControls.Button
Protected WithEvents nSave As System.Web.UI.WebControls.Button
Protected WithEvents nMessage As System.Web.UI.WebControls.Label
Protected WithEvents nDelete As System.Web.UI.WebControls.Button
Protected WithEvents nModify As System.Web.UI.WebControls.Button
Protected WithEvents nAdd As System.Web.UI.WebControls.Button
Protected WithEvents nPrint As System.Web.UI.WebControls.Button
Protected WithEvents nFilter As System.Web.UI.WebControls.Button
Protected WithEvents nFirst As System.Web.UI.WebControls.ImageButton
Protected WithEvents nRemoveFilter As System.Web.UI.WebControls.Button
However, this is not desirable because these declarations are already present in the base web form class. Is there a way to avoid this automatic insertion of undesired code?
It is easy when you know it.
-
Mar 10th, 2005, 11:36 PM
#2
Thread Starter
Hyperactive Member
Re: Problem on inheriting from web form
Am I using the right technique of programming?
It is easy when you know it.
-
Mar 15th, 2005, 12:29 AM
#3
Thread Starter
Hyperactive Member
Re: Problem on inheriting from web form
Does anybody inherit from web forms, or am I the only one doing it? Please somebody answer!
It is easy when you know it.
-
Mar 16th, 2005, 08:28 AM
#4
I wonder how many charact
Re: Problem on inheriting from web form
There is no way to avoid it other than DO NOT ENTER DESIGN MODE. I exclusively use the HTML designer tab - and rarely if ever hit the Designer.
-
Mar 16th, 2005, 01:53 PM
#5
Addicted Member
Re: Problem on inheriting from web form
In ASP.NET 2.0 & VS2005 you will no longer have this problem. All the 'Generated Code' goes away and the designer does not try to format your code for you anymore.
-
Mar 16th, 2005, 09:39 PM
#6
I wonder how many charact
Re: Problem on inheriting from web form
Well, when VS 2005 comes out he can use templates instead - but the fact is its not due out until late fall.
-
Mar 17th, 2005, 01:40 AM
#7
Thread Starter
Hyperactive Member
Re: Problem on inheriting from web form
Thanks a lot Nemaroller & RDove! What are templates?
It is easy when you know it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|