473,324 Members | 2,002 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,324 software developers and data experts.

Conditional Compilation and Duplicate IDs

Hi all experts,

I am having a problem below.
Expand|Select|Wrap|Line Numbers
  1. <% #if ALADDIN %> 
  2.     <asp:Button ID="Button2" runat="server" Text="Button 1" /> 
  3. <% #elif ALADDINP %> 
  4.     <asp:Button ID="Button2" runat="server" Text="Button 2" /> 
  5. <% #endif %>

I am merging code together and above is a portion of source code in aspx file. I have added conditional compilation already and everything seems properly except this case. It has an error because of duplicate ID value, do you any way to pass this issue without change the ID value.

thanks,
Oct 25 '13 #1

✓ answered by Frinavale

You could try something like:
Expand|Select|Wrap|Line Numbers
  1. <asp:Button ID="Button2" runat="server" Text='<%# ALADDIN == true  ? "Button 1" : "Button 2" %>' />
-Frinny

6 1506
Frinavale
9,735 Expert Mod 8TB
It is probably a lot easier to solve this if you just set the text of your button in your server-side c# or vb.net code.

Put it in your Page Load event and just set the Text property of the button.

Are you using asp.net or asp classic?

-Frinny
Oct 25 '13 #2
Thanks Frinny,

I'm using the ASP.NET

Actually i don't want to change the current code, because i have a lot of files and they take more time to do all of them. It seems that we don't have a way to pass this issue, doesn't it?
Oct 28 '13 #3
Frinavale
9,735 Expert Mod 8TB
You could try something like:
Expand|Select|Wrap|Line Numbers
  1. <asp:Button ID="Button2" runat="server" Text='<%# ALADDIN == true  ? "Button 1" : "Button 2" %>' />
-Frinny
Oct 28 '13 #4
Thank Frinny,

but i meet an error like
"The name 'ALADDIN' does not exist in the current context"

what do i do now ?

thanks,
Oct 29 '13 #5
Frinavale
9,735 Expert Mod 8TB
You could use two different IDs, implement one method that handles the click event for both buttons, and then supply the method's name to the OnClick of both buttons.

-Frinny
Oct 29 '13 #6
Thank Frinavale...

we can apply this way

<asp:Button ID="Button2" runat="server" Text='<%# textbehind() %>' />

and in the behind code, we make a function textbehind() and process inside it. We also need to call Page.DataBind() on the page_load function.

thanks,
Nov 1 '13 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Steven T. Hatton | last post by:
I've made no secret of the fact that I really dislike the C preprocessor in C++. No aspect of the language has caused me more trouble. No aspect of the language has cause more code I've read to be...
2
by: Steve Jorgensen | last post by:
To begin with an example... Let's say you were wanting to write code usign early binding to the MSXML library, but then be able to switch between early and late binding at will. Conditional...
1
by: chris han | last post by:
Hi, all, I'm trying to use Conditional Compilation Statements in my code. using System; #define DEBUG public class MyClass { public static void Main() {
12
by: wanghz | last post by:
Hi, Could I ask some questions about the conditional compilaion? Suppose I have three simple files: a.c, b.c and c.h /* --------a.c--------- */ #include <stdio.h> #include "c.h" int...
1
by: lavu | last post by:
Is there any way to specify a different executable name for my project based on value that I have set in my conditional compilation constant. For eg: If I have FIRST specified in my conditional...
28
by: richardlang | last post by:
Anyone out there ever come across a preprocessor macro that compares an argument value against the predefined __DATE__ macro in order to control conditional compilation based on date. Something...
4
by: Bob | last post by:
Hi, In VS2003 conditional compilation constants and their state could be defined at project level. I was using this to control what features where offered by various builds. i.e....
10
by: Dave | last post by:
I'm a C++ programmer of many years, trying to get my feet wet in C#. I have a question about conditional compilation. In C++, I would sometimes define a constant in an include file, and then...
6
by: maxwell | last post by:
I'm trying to use the gpp utility (Gnu points to http://en.nothingisreal.com/wiki/GPP) to do conditional compilation in Python, and I'm running into a problem: the same '#' character introduces...
1
by: Sagaert Johan | last post by:
Hi Is there a constant i could use to force conditional compilation based on whether i compile for CF or the Full NET framework ? Johan
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.