I have some legacy ASP code that looks like this:
<%
if not (Rs.EOF) then
i=0
do while not Rs.EOF
i=i+1
PaymentItemName = Rs("PaymentItem Name")
PaymentItemCode = Rs("PaymentItem Code")
%>
<tr>
<td><input type="text" name="PaymentIt emName_N<%=i%>" size="20"
value="<%=Payme ntItemName%>" style="backgrou nd:#D5FFC8"
<%=Use_permissi on%>></td>
<td></td>
<td><input type="text" name="PaymentIt emCode_N<%=i%>" size="10"
value="<%=Payme ntItemCode%>" <%=Use_permissi on%>></td>
</tr>
<%
loop
end if
%>
What would be the C#.NET equivilent?
I tried (snipped for ease of reading):
<td><input type="text" name="PaymentIt emName_N<%=i;%> " size="20"
value="<%=Payme ntItemName;%>" style="backgrou nd:#D5FFC8"
<%=Use_permissi on;%>></td>
and I just get errors. 2 1683
We don't need to use the semi-colon in a data binding expression as you
show. Now you should also submit he following search term to google or
whatever...
eval data binder
<%= Clinton Gallagher
NET csgallagher AT metromilwaukee. com
URL http://clintongallagher.metromilwaukee.com/
"Andrew Hayes" <An*********@di scussions.micro soft.comwrote in message
news:BB******** *************** ***********@mic rosoft.com...
>I have some legacy ASP code that looks like this:
<%
if not (Rs.EOF) then
i=0
do while not Rs.EOF
i=i+1
PaymentItemName = Rs("PaymentItem Name")
PaymentItemCode = Rs("PaymentItem Code")
%>
<tr>
<td><input type="text" name="PaymentIt emName_N<%=i%>" size="20"
value="<%=Payme ntItemName%>" style="backgrou nd:#D5FFC8"
<%=Use_permissi on%>></td>
<td></td>
<td><input type="text" name="PaymentIt emCode_N<%=i%>" size="10"
value="<%=Payme ntItemCode%>" <%=Use_permissi on%>></td>
</tr>
<%
loop
end if
%>
What would be the C#.NET equivilent?
I tried (snipped for ease of reading):
<td><input type="text" name="PaymentIt emName_N<%=i;%> " size="20"
value="<%=Payme ntItemName;%>" style="backgrou nd:#D5FFC8"
<%=Use_permissi on;%>></td>
and I just get errors.
Thanks for the pointer.
I trawled through the results looking for how to use the <%# ... %code to
set the property of a control, and after much trial and error this is what
I've found:
<%@ Page Language="C#" AutoEventWireup ="true" Inherits="_Defa ult" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>ASP.NE T 2.0 Projects</title>
<script language="C#" runat="server">
String[] urlArray = {"http://localhost/Corporate",
"http://localhost/FormViewData/employees.aspx" ,
"http://localhost/Membership",
"http://localhost/TestASP",
"http://localhost/Worklist"};
String[] textArray = {"Corporate Website",
"FormViewDa ta",
"Membership ",
"TestASP",
"Worklist"} ;
Int32 count;
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>ASP.NET 2.0 Projects</h1>
<%
for (count = 0; count < urlArray.Length ; count++)
{
Page.DataBind() ;
%>
<br />
<asp:HyperLin k runat="server" NavigateUrl="<% # urlArray[count]
%>"><%=textArra y[count]%></asp:HyperLink>< br />
<%
}
%>
</div>
</form>
</body>
</html>
Only by using <%# urlArray[count] %can I set the NavigateURL property of
the HyperLink control. And only by calling Page.DataBind() on every iteration
of the loop can I ensure that the urlArray[count] variable has the correct
value. If I don't, then it always returns urlArray[0].
I can also use the older ASP syntax <%=textArray[count]%>, but only when not
assigning it to a property. Using NavigateURL="<% =urlArray[count]%>" will set
the property to the literal string.
Why this is the case puzzles me. In older ASP code, the <%=...%syntax is
often used to assign values to button text, dropdown list items, and control
names, but while the syntax is supported in ASPX, it doesn't work the same
way for control property assignments, meaning you have to rewrite all the ASP
code.
So this ASP code:
<td><input type="text" name="PaymentIt emName_N<%=i%>" size="20"
value="<%=Payme ntItemName%>" style="backgrou nd:#D5FFC8"
<%=Use_permissi on%>></td>
Becomes this ASPX code:
<td><input type="text" name="<%# PaymentItemCont rolName(i) %>" size="20"
value="<%# PaymentItemName %>" style="backgrou nd:#D5FFC8"
<%=Use_permissi on%>></td>
Where PaymentItemCont rolName() returns a String which is a concatenation of
"PaymentItemNam e_N" and i, PaymentItemName has to be an eval as it's assigned
to a property, but Use_permission doesn't as it's a string literal. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Darren |
last post by:
Hi. I have a javascript menu system which uses the "elementFromPoint"
function. However Netscape/Mozilla doesn't recognise this function. Does it
have an equivilent?
Thanks
--
Darren
|
by: John Galt |
last post by:
I was looking at a VB.NET program that is passing strings to method calls
using ByVal. I was wondering if this is for a reason and, if so, should a C#
conversion of code samples from VB.NET also use an equivilent rather than
passing strings by reference?
|
by: trint |
last post by:
I can't find the followings equivilent:
flashPlayer.Movie = Application.StartupPath + @"/Cooler2.swf";
flashPlayer.FSCommand +=new
AxShockwaveFlashObjects._IShockwaveFlashEvents_FSCommandEventHandler(flashPlayer_FSCommand);
Any help is appreciated.
Thanks,
Trint
|
by: Steve1 via DotNetMonster.com |
last post by:
Hi all,
I'm producing a data conversion app in C#. I have the code already written
in VB6. I would to know if anyone knows of any links that shows the VB6
function/syntax equivilent in C#? For example in the VB6 code it has 'While
rsSource.EOF' and 'Set rsTarget = ddTarget.OpenRecordset("SELECT * .....
etc...etc' , is there any links that will show me the C# equivilent???
Thanks in advance,
Steve.
|
by: Ryan Ternier |
last post by:
I'm trying to find an equivilent function to VB's DatePart function.
I have a Year, Month, the Day of week (Sunday, monday etc.) and the week
(week 1, week 2) and I need to find the date of that month.
Can anyone help me with this?
/RT
| |
by: nic |
last post by:
Hi,
I need to get the equivilent of Response.Redirect
(~/mypage.aspx) for a dynamic javascript function.
Essentially I am writing the javascript on the non-code
behind page and need to inject the "~" so I can have a
relative path to my page. So here is the javascript
function:
function showHelp(fieldID)
{
|
by: dkode8 |
last post by:
Hello,
I am creating an application that uses impersonation to log a user into
our domain and then show them the contents of their network share where
they store their files.
I have all the permissions and impersonation working correctly, Now I
have hit a snag on how to get my idea to work..
Right now i have default.aspx, and Directory.cs
|
by: Andy Fish |
last post by:
Hi,
In my aspx web application, I am generating a list of items in a menu down
the left-hand side. Different items in the list may have different controls
in, and this is data-driven at runtime.
At the moment I am using a custom template control similar to a repeater but
with many different templates. However, It's a bit of a pain to work with
and maintain. What I would like to do is generate the list of menu items
using XSLT
|
by: MikeLing |
last post by:
Hi,
String.IndexOf is case sensitive so I need to covert to lower before testing
the string contains a given string. In VB this is:
Instr(Lcase(StringToTest, "StringToCheckFor"))
What is the C# equivilent? The closest I've comeup with is:
string lowerString = testString.ToLower();
|
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: 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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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.
| |