I have strange problem. If in Design Mode and I drag a
Web Server Control onto the form, Visual Studio
automatically declares the control for me in the code
behind page.
However, if I'm working in HTML mode and I manually enter
the the Web Server Control, nothing is written in the
code behind page. If I declare the control myself and
attempt to use it, I get an error stating something
like, "ojbect not ininialize".
I have a DataList control on my page and inside the
<ItemTemplate > I inserted (by typing) a <asp:Label ID="x"
runat="server" />. I then declared the label myself
inside the Code Behind Page as:
protected System.Web.UI.W ebControls.Labe l x;
if I then try to set the Text property of the label, I
get the error mentioned above. Can someone please help
me out here and first explain what is going on then give
me the solution or at least where I can find the solution.
thanks,
Prince 3 1404
The change in the CodeBehind is triggered when you go to Design view.
--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
"Prince" <an*******@disc ussions.microso ft.com> wrote in message
news:1a******** *************** *****@phx.gbl.. . I have strange problem. If in Design Mode and I drag a Web Server Control onto the form, Visual Studio automatically declares the control for me in the code behind page.
However, if I'm working in HTML mode and I manually enter the the Web Server Control, nothing is written in the code behind page. If I declare the control myself and attempt to use it, I get an error stating something like, "ojbect not ininialize".
I have a DataList control on my page and inside the <ItemTemplate > I inserted (by typing) a <asp:Label ID="x" runat="server" />. I then declared the label myself inside the Code Behind Page as:
protected System.Web.UI.W ebControls.Labe l x;
if I then try to set the Text property of the label, I get the error mentioned above. Can someone please help me out here and first explain what is going on then give me the solution or at least where I can find the solution.
thanks, Prince
Prince,
You can't declare a control inside an itemtemplate like that. That
doesn't work because the datalist will need to create numerous copies of
them so how would it know which one to set.
What you have to do is create a function to handle an event such as
ItemDataBound of the datalist. Then you can access the label in that
particular item as so:
Label lblX = (Label) e.Item.FindCont rol("lblX");
Then you can access it, though you may want to do a quick check to
see if the label is null before you access it's properties.
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
"Prince" <an*******@disc ussions.microso ft.com> wrote in message
news:1a******** *************** *****@phx.gbl.. . I have strange problem. If in Design Mode and I drag a Web Server Control onto the form, Visual Studio automatically declares the control for me in the code behind page.
However, if I'm working in HTML mode and I manually enter the the Web Server Control, nothing is written in the code behind page. If I declare the control myself and attempt to use it, I get an error stating something like, "ojbect not ininialize".
I have a DataList control on my page and inside the <ItemTemplate > I inserted (by typing) a <asp:Label ID="x" runat="server" />. I then declared the label myself inside the Code Behind Page as:
protected System.Web.UI.W ebControls.Labe l x;
if I then try to set the Text property of the label, I get the error mentioned above. Can someone please help me out here and first explain what is going on then give me the solution or at least where I can find the solution.
thanks, Prince
Good explanation. Thanks. -----Original Message----- Prince, You can't declare a control inside an
itemtemplate like that. Thatdoesn't work because the datalist will need to create
numerous copies ofthem so how would it know which one to set.
What you have to do is create a function to
handle an event such asItemDataBoun d of the datalist. Then you can access the
label in thatparticular item as so:
Label lblX = (Label) e.Item.FindCont rol("lblX");
Then you can access it, though you may want to
do a quick check tosee if the label is null before you access it's
properties. Hope this helps, Mark Fitzpatrick Microsoft MVP - FrontPage
"Prince" <an*******@disc ussions.microso ft.com> wrote in
messagenews:1a******* *************** ******@phx.gbl. ..I have strange problem. If in Design Mode and I drag a Web Server Control onto the form, Visual Studio automatically declares the control for me in the code behind page.
However, if I'm working in HTML mode and I manually
enter the the Web Server Control, nothing is written in the code behind page. If I declare the control myself and attempt to use it, I get an error stating something like, "ojbect not ininialize".
I have a DataList control on my page and inside the <ItemTemplate > I inserted (by typing) a <asp:Label
ID="x" runat="server" />. I then declared the label myself inside the Code Behind Page as:
protected System.Web.UI.W ebControls.Labe l x;
if I then try to set the Text property of the label, I get the error mentioned above. Can someone please help me out here and first explain what is going on then
give me the solution or at least where I can find the
solution. thanks, Prince
. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Richard Dixson |
last post by:
I created a new C# web application. Basically all I am trying to do is
create a table that consists of a few rows with two columns in each. And
then to set those columns to text values from my code behind. However I am
not able to do this at all, I am going about this wrong, I think and need
guideance.
If this was just straight HTML I would do this:
<table>
<tr><td>field 1</td><td>value 1 set by code behind</td></tr>
|
by: tshad |
last post by:
Many (if not most) have said that code-behind is best if working in teams -
which does seem logical.
How do you deal with the flow of the work?
I have someone who is good at designing, but know nothing about ASP. He can
build the design of the pages in HTML with tables, labels, textboxes etc.
But then I would need to change them to ASP.net objects and write the code
to make the page work (normally I do this as I go - can't do this...
|
by: Me |
last post by:
Hi,
I inherited a web application that has several very similar forms for
gathering user data. User's must choose the form that best fits their needs
and fill it out. Each form has about 15 questions that are the same and a
few that are different.
The problem is that each form contains duplicate UI code and duplicate code
in the code behind to handle these duplicate questions... I know, but I
inherited the app.
|
by: rn5a |
last post by:
Assume that a user control (MyUC.ascx) encapsulates 2 TextBoxes with
the IDs 'txt1' & 'txt2' respectively. To use this user control in an
ASPX page, the following Register directive will be required:
<%@ Register TagPrefix="UC" TagName="MyUserCtrl" Src="MyUC.ascx" %>
Assuming that the ASPX page doesn't use a code-behind, I can access the
properties, events etc. of the user control in the ASPX page in this
way (assume that the ASPX page...
|
by: ChrisD76 |
last post by:
Hi,
I am new to using VBA, and have been working with DAO Recordsets. I'm working on a little problem, and think that DAO Recordsets are the solution. I've been playing around with them to try and get it working, and have the following code, which works perfectly:
Function ReadCourseContent()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDb()
Set rst =...
| |
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |