Forum Moderators: open

Message Too Old, No Replies

Help with c# in an ASPX page

         

pauld

6:56 am on May 22, 2003 (gmt 0)

10+ Year Member



hello
I got this .aspx page with no access to the source code.(apparently it was lost)

anyways. I have this form with a datagrid that access values from a database.

<TD align="left" width="293"><asp:dropdownlist id="DropDownList16" runat="server" AutoPostBack="True"></asp:dropdownlist></TD>
<TD align="middle" width="127">$<asp:label id="Label32" runat="server">0</asp:label></TD>

If you look at the code above, asp:dropdownlist is a string, but I'm not sure if asp:label is a numeric. Since I don't have the source code, how can I change the numeric value that gets to the asp:label within the aspx page.
lets say i get a number 20, and I want to add 15 to it, how can this be done.

any help would be appreciated
thank you

sharbel

12:29 pm on May 22, 2003 (gmt 0)

10+ Year Member



The value from a Label will always be returned as a string, because you are accessing it from its "Text" property. So to get it to an integer, you would simply use the Convert function... add what you want to it, then send it back to the label:

int myInteger = Convert.ToInt32(Label1.Text);
myInteger = myInteger + 10; //adding 10 or whatever you want to it.
Label1.Text = myInteger.ToString();

pauld

5:07 pm on May 22, 2003 (gmt 0)

10+ Year Member



thank you and where should I put this code. Here's the complete code

I don't have Visual studio. I can only work on Dreamweaver or Web Matrix
here's the complete code,
what I'm trying to do is wherever it says <asp:label id="Labelsomenumber" runat="server">0</asp:label>
replace the value of the label by multiplying a number with it for ex : label*25 and display it.

<%@ Import Namespace="Web.Common" %>
<%@ import Namespace="System.Data.SqlClient" %>
<%@ import Namespace="System.Data" %>
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="true" Inherits="Web.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content="False" name="vs_showGrid">
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<!--body MS_POSITIONING="GridLayout"-->
</HEAD>
<body bgColor="#ffffff">
<form id="Form2" runat="server">
<font face="Verdana"><strong></strong></font>
<table width="800" border="0">
<!--DWLayoutTable-->
<tbody>
<tr>
<td vAlign="top" colSpan="2" rowSpan="3"><IMG height="113" src="images/step_icons_04.gif" width="227" useMap="#Map" border="0">
</td>
<td width="290" height="27">
</td>
<td vAlign="top" align="right" colSpan="2"><IMG height="25" src="images/preparefor.gif" width="265"></td>
</tr>
<tr>
<td height="38">
</td>
<td width="32">
</td>
<td width="231">
</td>
</tr>
<tr>
<td vAlign="top" width="146" rowSpan="2"></td>
<td width="79" height="29"></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="9"></td>
<td><IMG height="36" src="images/step_icons_06.gif" width="143"></td>
<td colSpan="2"><asp:imagebutton id="ImageButton1" runat="server" ImageUrl="images/continue.gif"></asp:imagebutton></td>
<td></td>
</tr>
</tbody>
</table>
<table style="WIDTH: 600px; HEIGHT: 303px" cellSpacing="5" width="600" align="left">
<!--DWLayoutTable-->
<tbody>
<tr vAlign="center">
<td vAlign="top" colSpan="2" height="21">Compatible System ****</FONT></STRONG>
</td>
<td align="middle"></td>
</tr>
<tr vAlign="center">
<td vAlign="top" width="164" bgColor="#f76423" height="21"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><strong>Options
</strong></font>
</td>
<td align="left" width="293" bgColor="#f76423">
<div align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><strong>Select
Options </strong></font>
</div>
</td>
<td align="middle" width="127" bgColor="#f76423">
<div align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><strong>Price</strong></font>
</div>
</td>
</tr>
<TR>
<TD align="left" width="164" height="21"><asp:label id="Label33" runat="server" Font-Bold="True">Label</asp:label></TD>
<TD align="left" width="293"><asp:label id="Label34" runat="server">Label</asp:label></TD>
<TD align="middle" width="127">$<asp:label id="Label35" runat="server">0</asp:label></TD>
</TR>
<TR>
<TD align="left" width="164" height="21"><asp:label id="Label36" runat="server" Font-Bold="True">Label</asp:label></TD>
<TD align="left" width="293"><asp:label id="Label38" runat="server">Label</asp:label></TD>
<TD align="middle" width="127">$<asp:label id="Label39" runat="server">0</asp:label></TD>
</TR>
<TR>
<TD align="left" width="164" height="21"><asp:label id="Label37" runat="server" Font-Bold="True">Label</asp:label></TD>
<TD align="left" width="293">
<asp:label id="Label41" runat="server">Label</asp:label></TD>
<TD align="middle" width="127">$<asp:label id="Label40" runat="server">0</asp:label></TD>
</TR>
<TR>
<TD align="left" width="164" height="21"><asp:label id="Label1" runat="server" Font-Bold="True" Width="134px">Label</asp:label></TD>
<TD align="left" width="293"><asp:dropdownlist id="DropDownList1" runat="server" AutoPostBack="True"></asp:dropdownlist></TD>
<TD align="middle" width="127">$<asp:label id="Label17" runat="server">0</asp:label></TD>
</TR>
<TR>
<TD align="left" width="164" height="21"><asp:label id="Label2" runat="server" Font-Bold="True">Label</asp:label></TD>
<TD align="left" width="293"><asp:dropdownlist id="DropDownList2" runat="server" AutoPostBack="True"></asp:dropdownlist></TD>
<TD align="middle" width="127">$<asp:label id="Label19" runat="server">0</asp:label></TD>
</TR>
<TR>
<TD align="left" width="164" height="21"><asp:label id="Label3" runat="server" Font-Bold="True">Label</asp:label></TD>
<TD align="left" width="293"><asp:dropdownlist id="DropDownList3" runat="server" AutoPostBack="True"></asp:dropdownlist></TD>
<TD align="middle" width="127">$<asp:label id="Label20" runat="server">0</asp:label></TD>
</TR>
<TR>
<TD style="HEIGHT: 30px" align="left" width="164" height="30"><asp:label id="Label4" runat="server" Font-Bold="True">Label</asp:label></TD>
<TD style="HEIGHT: 30px" align="left" width="293"><asp:dropdownlist id="DropDownList4" runat="server" AutoPostBack="True"></asp:dropdownlist></TD>
<TD style="HEIGHT: 30px" align="middle" width="127">$<asp:label id="Label21" runat="server">0</asp:label></TD>
</TR>
<TR>
<TD align="left" width="164" height="21"><asp:label id="Label5" runat="server" Font-Bold="True">Label</asp:label></TD>
<TD align="left" width="293"><asp:dropdownlist id="DropDownList5" runat="server" AutoPostBack="True"></asp:dropdownlist></TD>
<TD align="middle" width="127">$<asp:label id="Label22" runat="server">0</asp:label></TD>
</TR>
<TR>
<TD align="left" width="164" height="21"><asp:label id="Label7" runat="server" Font-Bold="True">Label</asp:label></TD>
<TD align="left" width="293"><asp:dropdownlist id="DropDownList7" runat="server" AutoPostBack="True"></asp:dropdownlist></TD>
<TD align="middle" width="127">$<asp:label id="Label23" runat="server">0</asp:label></TD>
</TR>
<TR>
<TD align="left" width="164" height="21"><asp:label id="Label8" runat="server" Font-Bold="True">Label</asp:label></TD>
<TD align="left" width="293"><asp:dropdownlist id="DropDownList8" runat="server" AutoPostBack="True"></asp:dropdownlist></TD>
<TD align="middle" width="127">$<asp:label id="Label24" runat="server">0</asp:label></TD>
</TR>
<TR>
<TD align="left" width="164" height="21"><asp:label id="Label9" runat="server" Font-Bold="True">Label</asp:label></TD>
<TD align="left" width="293"><asp:dropdownlist id="DropDownList9" runat="server" AutoPostBack="True"></asp:dropdownlist></TD>
<TD align="middle" width="127">$<asp:label id="Label25" runat="server">0</asp:label></TD>
</TR>
<TR>
<TD align="left" width="164" height="21"><asp:label id="Label10" runat="server" Font-Bold="True">Label</asp:label></TD>
<TD align="left" width="293"><asp:dropdownlist id="DropDownList10" runat="server" AutoPostBack="True"></asp:dropdownlist></TD>
<TD align="middle" width="127">$<asp:label id="Label26" runat="server">0</asp:label></TD>
</TR>
<TR>
<TD align="left" width="164" height="21"><asp:label id="Label11" runat="server" Font-Bold="True">Label</asp:label></TD>
<TD align="left" width="293"><asp:dropdownlist id="DropDownList11" runat="server" AutoPostBack="True"></asp:dropdownlist></TD>
<TD align="middle" width="127">$<asp:label id="Label27" runat="server">0</asp:label></TD>
</TR>
<TR>
<TD align="left" width="164" height="21"><asp:label id="Label12" runat="server" Font-Bold="True">Label</asp:label></TD>
<TD align="left" width="293"><asp:dropdownlist id="DropDownList12" runat="server" AutoPostBack="True"></asp:dropdownlist></TD>
<TD align="middle" width="127">$<asp:label id="Label28" runat="server">0</asp:label></TD>
</TR>
<TR>
<TD align="left" width="164" height="21"><asp:label id="Label13" runat="server" Font-Bold="True">Label</asp:label></TD>
<TD align="left" width="293"><asp:dropdownlist id="DropDownList13" runat="server" AutoPostBack="True"></asp:dropdownlist></TD>
<TD align="middle" width="127">$<asp:label id="Label29" runat="server">0</asp:label></TD>
</TR>
<TR>
<TD align="left" width="164" height="21"><asp:label id="Label14" runat="server" Font-Bold="True">Label</asp:label></TD>
<TD align="left" width="293"><asp:dropdownlist id="DropDownList14" runat="server" AutoPostBack="True"></asp:dropdownlist></TD>
<TD align="middle" width="127">$<asp:label id="Label30" runat="server">0</asp:label></TD>
</TR>
<TR>
<TD align="left" width="164" height="21"><asp:label id="Label15" runat="server" Font-Bold="True">Label</asp:label></TD>
<TD align="left" width="293"><asp:dropdownlist id="DropDownList15" runat="server" AutoPostBack="True"></asp:dropdownlist></TD>
<TD align="middle" width="127">$<asp:label id="Label31" runat="server">0</asp:label></TD>
</TR>
<TR>
<TD align="left" width="164" height="21"><asp:label id="Label16" runat="server" Font-Bold="True">Label</asp:label></TD>
<TD align="left" width="293"><asp:dropdownlist id="DropDownList16" runat="server" AutoPostBack="True"></asp:dropdownlist></TD>
<TD align="middle" width="127">$<asp:label id="Label32" runat="server">0</asp:label></TD>
</TR>
<TR>
<TD align="left" width="164" height="21"></TD>
<TD align="left" width="293"><asp:label id="Label18" runat="server" Font-Bold="True">Sub Total</asp:label>
<TD align="middle" width="127">$<asp:label id="Label6" runat="server">0</asp:label></TD>
</TR>
<TR>
<TD align="left" width="164" height="21"></TD>
<TD align="left" width="293"><asp:datagrid id="DataGrid1" runat="server"></asp:datagrid></TD>
<TD align="middle" width="127"></TD>
</TR>
</form>
</TBODY></TABLE>
</body>
</HTML>

sharbel

11:50 pm on May 22, 2003 (gmt 0)

10+ Year Member



The code will be placed in the event handler that you want it to run at. For example, if you have a button that you click to execute the code, then you would place it in the Button_Click event.

I havent worked with Dreamweaver for .NET apps, but I can see in your html markup that you are referring to a codebehind file, so your code for the event will be placed in the code behind.. again, I am not a Dreamweaver user, so I cant help you much with how its accomplished in DW.