473,416 Members | 1,571 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,416 software developers and data experts.

Convert ASP.NET script to code behind

Hi,

I have this code in my ASP.NET and I want to convert it to C# (code behind)

<asp:Repeater id="subCategoryRepeater" runat="server">
<ItemTemplate>
<ul>
<li>
<asp:HyperLink id="subCategoryHyperLink" runat="server" NavigateUrl='<%#
"subcategory.aspx?subcategoryid=" +
Convert.ToString(DataBinder.Eval(Container.DataIte m, "id")) %>'>
<%# Convert.ToString(DataBinder.Eval(Container.DataIte m, "name")) %>
</asp:HyperLink>
</li>
</ul>
</ItemTemplate>
</asp:Repeater>

And this is my code behind:

private void subCategoryName(SqlString categoryId) {
subcat.CategoryId = categoryId.ToSqlDecimal();
DataTable dataTable = subcat.SelectAllWcategoryIdLogic();

subCategoryRepeater.DataSource = dataTable;
subCategoryRepeater.DataBind();
}
Any help ?

thanks
Nov 19 '05 #1
3 2673
Rename your old file as .txt and bring it into the project as an existing
item.

Load the .txt file in the IDE and use it as a reference.

Load a new form, add the same type of controls to the new form that were
used in the now renamed .txt file, modify the property names of the controls
to match those in the .txt file and then copy reusable source from the .txt
file into the new form where it is needed in the .aspx or the .cs
code-behind.

-- or --

you have to write the declaration and signature for each control in the
code-behind yourself.

I think my suggested approach to rename and reuse is easier and fastest.
--
<%= Clinton Gallagher
METROmilwaukee "Regional Information Services"
NET csgallagher AT metromilwaukee.com
URL http://clintongallagher.metromilwaukee.com/

"Thubaiti" <Th******@discussions.microsoft.com> wrote in message
news:78**********************************@microsof t.com...
Hi,

I have this code in my ASP.NET and I want to convert it to C# (code behind)
<asp:Repeater id="subCategoryRepeater" runat="server">
<ItemTemplate>
<ul>
<li>
<asp:HyperLink id="subCategoryHyperLink" runat="server" NavigateUrl='<%#
"subcategory.aspx?subcategoryid=" +
Convert.ToString(DataBinder.Eval(Container.DataIte m, "id")) %>'>
<%# Convert.ToString(DataBinder.Eval(Container.DataIte m, "name")) %>
</asp:HyperLink>
</li>
</ul>
</ItemTemplate>
</asp:Repeater>

And this is my code behind:

private void subCategoryName(SqlString categoryId) {
subcat.CategoryId = categoryId.ToSqlDecimal();
DataTable dataTable = subcat.SelectAllWcategoryIdLogic();

subCategoryRepeater.DataSource = dataTable;
subCategoryRepeater.DataBind();
}
Any help ?

thanks

Nov 19 '05 #2
when I wrote this code, there is a compiler error about "Container" ?!

Convert.ToString(DataBinder.Eval(Container.DataIte m, "name"));
Is there any way to convert "ONLY" this statement to code behind ??

<%# Convert.ToString(DataBinder.Eval(Container.DataIte m, "name")) %>

Thanks...
"clintonG" wrote:
Rename your old file as .txt and bring it into the project as an existing
item.

Load the .txt file in the IDE and use it as a reference.

Load a new form, add the same type of controls to the new form that were
used in the now renamed .txt file, modify the property names of the controls
to match those in the .txt file and then copy reusable source from the .txt
file into the new form where it is needed in the .aspx or the .cs
code-behind.

-- or --

you have to write the declaration and signature for each control in the
code-behind yourself.

I think my suggested approach to rename and reuse is easier and fastest.
--
<%= Clinton Gallagher
METROmilwaukee "Regional Information Services"
NET csgallagher AT metromilwaukee.com
URL http://clintongallagher.metromilwaukee.com/

"Thubaiti" <Th******@discussions.microsoft.com> wrote in message
news:78**********************************@microsof t.com...
Hi,

I have this code in my ASP.NET and I want to convert it to C# (code

behind)

<asp:Repeater id="subCategoryRepeater" runat="server">
<ItemTemplate>
<ul>
<li>
<asp:HyperLink id="subCategoryHyperLink" runat="server" NavigateUrl='<%#
"subcategory.aspx?subcategoryid=" +
Convert.ToString(DataBinder.Eval(Container.DataIte m, "id")) %>'>
<%# Convert.ToString(DataBinder.Eval(Container.DataIte m, "name")) %>
</asp:HyperLink>
</li>
</ul>
</ItemTemplate>
</asp:Repeater>

And this is my code behind:

private void subCategoryName(SqlString categoryId) {
subcat.CategoryId = categoryId.ToSqlDecimal();
DataTable dataTable = subcat.SelectAllWcategoryIdLogic();

subCategoryRepeater.DataSource = dataTable;
subCategoryRepeater.DataBind();
}
Any help ?

thanks


Nov 19 '05 #3
Google: "Container.DataItem" produced [1],[2] which may help you understand
what needs to be done.
--
<%= Clinton Gallagher
METROmilwaukee "Regional Information Services"
NET csgallagher AT metromilwaukee.com
URL http://clintongallagher.metromilwaukee.com/

[1] http://weblogs.asp.net/rajbk/archive...20/188868.aspx
[2]
http://www.learnvisualstudio.net/vid...r_DataItem.htm

"Thubaiti" <Th******@discussions.microsoft.com> wrote in message
news:A3**********************************@microsof t.com...
when I wrote this code, there is a compiler error about "Container" ?!

Convert.ToString(DataBinder.Eval(Container.DataIte m, "name"));
Is there any way to convert "ONLY" this statement to code behind ??

<%# Convert.ToString(DataBinder.Eval(Container.DataIte m, "name")) %>

Thanks...
"clintonG" wrote:
Rename your old file as .txt and bring it into the project as an existing item.

Load the .txt file in the IDE and use it as a reference.

Load a new form, add the same type of controls to the new form that were
used in the now renamed .txt file, modify the property names of the controls to match those in the .txt file and then copy reusable source from the ..txt file into the new form where it is needed in the .aspx or the .cs
code-behind.

-- or --

you have to write the declaration and signature for each control in the
code-behind yourself.

I think my suggested approach to rename and reuse is easier and fastest.
--
<%= Clinton Gallagher
METROmilwaukee "Regional Information Services"
NET csgallagher AT metromilwaukee.com
URL http://clintongallagher.metromilwaukee.com/

"Thubaiti" <Th******@discussions.microsoft.com> wrote in message
news:78**********************************@microsof t.com...
Hi,

I have this code in my ASP.NET and I want to convert it to C# (code

behind)

<asp:Repeater id="subCategoryRepeater" runat="server">
<ItemTemplate>
<ul>
<li>
<asp:HyperLink id="subCategoryHyperLink" runat="server" NavigateUrl='<%# "subcategory.aspx?subcategoryid=" +
Convert.ToString(DataBinder.Eval(Container.DataIte m, "id")) %>'>
<%# Convert.ToString(DataBinder.Eval(Container.DataIte m, "name")) %>
</asp:HyperLink>
</li>
</ul>
</ItemTemplate>
</asp:Repeater>

And this is my code behind:

private void subCategoryName(SqlString categoryId) {
subcat.CategoryId = categoryId.ToSqlDecimal();
DataTable dataTable = subcat.SelectAllWcategoryIdLogic();

subCategoryRepeater.DataSource = dataTable;
subCategoryRepeater.DataBind();
}
Any help ?

thanks


Nov 19 '05 #4

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

Similar topics

5
by: Chung | last post by:
Hi All, Can anyone tell me how can I call a client script (javascript) from Code behind server code (c#)? Chung
1
by: Johann Blake | last post by:
My ASP.NET application is written using C# script as well as C# code-behind. After setting a breakpoint in the script and running the application, I click from one page to the next but when I...
4
by: Bob T | last post by:
Hi All, I am trying to pass a variable from my VB asp.net script (from for example Sub Page_Load in mypage.aspx.vb) to my Client side script. I have found and looked at a very good example...
8
by: Brett Robichaud | last post by:
I understand how code-behind can handle events for a page, but can I call a code-behind method from within a <script> tag in my ASP.Net page, or can I only call methods defined in other <script>...
1
by: Russ | last post by:
I've been trying to get my head around this for 3 days now and it seems like everything I try does not work for one reason or another. I built a test page using the TabStrip and MultiPage controls....
3
by: Dustin II. | last post by:
Hi, I have an ASP.NET solution, and the ASPX page I have a form , I want to copy some of the data from that form to the clipboard, I am using the below script the script works fine when I use a...
7
by: Alan Silver | last post by:
Hello, I have installed the 2.0 framework, and am looking at converting some of my 1.1 pages to use partial classes. I don't (yet) have VS2005, so I'm doing this by hand, but am having problems....
0
by: oliver | last post by:
QUESTION: How to access an object embedded in a UserControl through Javascript file? Another way to ask this question: How to execute script from a UserControl, accessing other objects in that...
10
by: Gary | last post by:
Hello, Anyone know how to do the following in c# - using inline codeblocks? <% If Request.Form("Name") = "Gary" Then %> <asp:RequiredFieldValidator ID="GarysValidation" ErrorMessage="Gary,...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
isladogs
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...
0
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...

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.