473,395 Members | 1,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

.Net 2.0: Programmatic Container selection

Hi,
I am trying to write a custom email form control that doesn't require
programming experiance in order to implement (for our html guys). I have a
base design that I would like to use for the markup but I am having trouble
getting it working.

<ec:intelleform runat="server" id="intelleform1" SubmitButtonId="FormSubmit"
Macro="$"
SmtpServer="<%$ AppSettings:SMTPServer %>">
<FormTemplate>
Hello
<asp:TextBox ID="YourName" Runat="server"></asp:TextBox><br>
sender <asp:TextBox ID="Sender" Runat="server"></asp:TextBox>
<asp:Button id="FormSubmit" Runat="server" Text="Email
it!"></asp:Button><br>
</FormTemplate>
<EmailTemplates>
<ec:EmailTemplate From="fo**@somewhere.com" To="so*****@somewhere.com">
<Template>
<strong>Your Name: </strong<%= YourName.Text %><br />
<strong>His Name: </strong<%= HisName.Text %><br />
</Template>
</ec:EmailTemplate>
</EmailTemplates>
</ec:intelleform>

<asp:TextBox ID="HisName" Runat="server">John</asp:TextBox>

---
The <formTemplateis where the email form controls get placed it is an
ITemplate.
Each <ec:EmailTemplatecontrols who the email goes to, from and the format
of the email body: <Template>.
The problem I have is when trying to use <%= YourName.Text %to write out
the Text value of teh YourName textbox I get the run-time error "The name
'YourName' does not exist in the current context"
is there any way around this?
I have noticed if I change the code to <%= (this.FindControl("YourName") as
TextBox).Text %it works.
I also have no problem with <%= HisName.Text %>< (which isnt in the
FormTemplate).
When I send the email its fine, it can find the references from the code and
renders the body apropriately.
I Instantiate the Itemplates into a temporary PlaceHolder then use
..RenderControl() into a HtmlTextWriter.
I hope this makes sense, I can provide more explantions and code if asked.

Cheers
Graham
Aug 7 '06 #1
1 1090
Hi Graham,

After reviewing your post, your question is "why cannot directly reference
the control placed inside a template". If I've misunderstood anything,
please feel free to post here.

I suppose you must be using attribute TemplateContainerAttribute to
designate a template container for your template. A template container type
is a simple Web control decorated with the INamingContainer interface.

Only controls put into the Page container can be reference directly using
its ID. For controls placed inside other container, you will have to first
get the reference to the container, then use its FindControl method to find
it.

Hope this helps. Please feel free to post here if anything is unclear.

Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 8 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Philippe Meunier | last post by:
Hi, I would like to know How I could draw a Dashed rectangle over everything in a container. I will use this to draw a selection rectangle (like in VB.NET Form Designer UI). And even it draws in...
1
by: Phil N | last post by:
Hi all. I've been here before and got a lot of help with my neophyte troubles so I'm back again. This time I have a number of questions (if I can remember them all). (I've pasted the code...
41
by: AngleWyrm | last post by:
I have created a new container class, called the hat. It provides random selection of user objects, both with and without replacement, with non-uniform probabilities. Uniform probabilities are a...
1
by: Keith Harris | last post by:
Hi, I have a Repeater control which is bound to a dataset. In the footer of the repeater control, I have a Button whose visibility I want to vary according to the sum of a column being > 0. ...
3
by: Hai Nguyen | last post by:
Hi everyone I have to generate a bunch of datagrids. The # number of datagrids needed will be told by a method. That's why I have to build an array of datagrids ..... Datagrids grids = new...
4
by: matt | last post by:
hello, i have a datagrid w/ a TemplateColumn in it, like so: <asp:TemplateColumn HeaderText="Select"> <ItemTemplate> <asp:CheckBox ID="chkSelected" Runat="server"/> </ItemTemplate>...
2
by: wubin_98 | last post by:
Hi All, Could any expert point out what is wrong in my code? I search around but couldn't found answer. It seems that I am the first person have this problem. Thanks in advanced I have a...
6
by: Blaine Manyluk | last post by:
I have a very unusual request. I need to be able to generate reports and save them as TIF files, with full programmatic control. The application will provide the filenames. Each page of the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.