I've a simple page in one of our web applications, which has the following markup:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="NewUpload.aspx.cs" Inherits="Mass_Upload.NewUpload" MasterPageFile="~/Master" Title="Document Mass Upload" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<link rel="Stylesheet" type="text/css" href="./../CSS/ScrollingTable.css" />
<script type="text/javascript" src="../Help/HelpPopup.js" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="CenterH1" runat="server">
Document Mass Upload <img style="Border:None;" src="../Help/help_icon.gif" />
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="CenterBody" runat="server">
<h3>Add New Upload</h3>
<table class="list">
<tr>
<td class="label" style="text-align:right;">Local File:</td>
<td class="normal">
<asp:FileUpload ID="fuFilename" runat="server" Width="405" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" Text="*"
ErrorMessage="A file to upload is required"
Display="Dynamic"
ControlToValidate="fuFilename"
ValidationGroup="DocumentUpload"
runat="server" />
</td>
</tr>
<tr>
<td class="label" style="text-align:right;">Document Description:</td>
<td class="normal">
<asp:TextBox ID="txtDescription" runat="server" Width="405" MaxLength="50" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" Text="*"
ErrorMessage="Document Description is a required field"
Display="Dynamic"
ControlToValidate="txtDescription"
ValidationGroup="DocumentUpload"
runat="server" />
</td>
</tr>
<tr>
<td class="label" style="text-align:right;">Document Type:</td>
<td class="normal">
<asp:DropDownList ID="ddDocType" runat="server" Width="405"/>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" Text="*"
ErrorMessage="Document Type is a required field"
Display="Dynamic"
ControlToValidate="ddDocType"
ValidationGroup="DocumentUpload"
runat="server" />
</td>
</tr>
<tr>
<td class="label" style="vertical-align:top;text-align:right;">Customer Types:</td>
<td class="normal">
<asp:Label ID="lblSingleCustomer" Text="Specific Code:" runat="server" /><asp:TextBox ID="txtSingleCustomer" runat="server" Width="100px" /><br />
<asp:CheckBoxList ID="cblCustomerTypes" runat="server" Width="405px" RepeatDirection="Horizontal" RepeatColumns="5" RepeatLayout="Table" CellPadding="10" CellSpacing="0" />
</td>
</tr>
<tr>
<td class="normal" colspan="2"> </td>
</tr>
<tr>
<td class="normal" colspan="2"><asp:Label ID="lblError" runat="server" Text="" ForeColor="Red"/></td>
</tr>
<tr>
<td class="normal" colspan="2">
<asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClick="BtnCancel_Click" CssClass="medium" />
<asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick="BtnUpload_Click" CssClass="medium" />
</td>
</tr>
</table>
</asp:Content>
It USED to work fine, but now, and without apparent change to code/design, both the "Upload" and "Cancel" buttons no longer work.
Putting a breakpoint in the codebehind's Page_Load() method shows that it is only called when the page is initially loaded, and not when the button is pressed.
Similarly, putting a breakpoint in the "BtnUpload_Click" event shows it is never called.
This is now not working both on my own development machine AND on the client's server (both when browsing to the servers page from my machine AND from the server itself).
It's important to stress that, between this working and it now not working, I am 90% sure nothing has changed in regards to the code.
Any help would be greatly appreciated, as the customer is rightly anxious - and i'm clueless as to what's causing it!
EDIT #1
Here's the codebehind for one of the buttons:
protected void BtnUpload_Click(object sender, EventArgs e)
{
if (DataAccess.CheckIfMassUploadAlreadyExists(fuFilename.FileName))
{
lblError.Text = "A file with the specified name already exists within the system.";
return;
}
else
{
try
{
UploadFile();
}
catch(Exception ex)
{
lblError.Text = ex.Message;// +"\nUsername:" + System.Web.HttpContext.Current.User.Identity.Name;
return;
}
}
}
.
Here's the reason.. and it's a really annoying reason too!
THIS:
<script type="text/javascript" src="../Help/HelpPopup.js" />
Should be THIS:
<script type="text/javascript" src="../Help/HelpPopup.js"></script>
Whoever decided the script tag needs to be treated differently to every other HTML tag, needs to be locked in a room with Justin Bieber.
First off all you should check your Validators and perhabs, comment them out for a test.
Is it possible that there are JavaScript-Errors showing on your page?
An ASP-Button is calling a JavaScript-Funktion (WebForm_DoPostBackWithOptions), if there is a JavaScript-Error "before" this line, sometimes you can't press a button.
apparently a client side "return false" is preventing the callback, this could be one of two reasons:
1-the validators always return not valid
2-some client script being called on the button returns false;
At the risk of being down voted for posting an answer to the title question which does not appear to be the OP's problem... I will offer this suggestion which fixed my similar problem:
<body background="images/GlobeBg.png" bgproperties="fixed">
</body>
Problem is, 'bgproperties' is NOT a valid attribute name even though some guys on the internet said it was. Other than an unnoticed squiggle underline in VWD 2008 Express, no error was emitted and the page otherwise looked normal. Simply, the update button and other input controls didn't work.
The cause for this for me was that a validator on another view in the same page was being fired, due to it being apart of the same validation group.So this prevented the post back.
Related
I'm in the process of converting an application into an ASP.NET Website. The way the page works is that the user puts in a list of machines in the box then click start, it goes through the list runs the checks and outputs the status and results to a text box on the left. In addition it puts a processing icon beside the check mark as it runs a check and removes it when the check is done. In my .NET application it works fine, but I can't figure out how to do it in ASP.NET
I've tried using Ajax controls to do this so I enclosed the status box in an update panel and put a timer that updates the panel every second.
In the code behind, right now I have a function that just rights out some test text to the results text panel, along with a 3 second pause to simulate the code in the back ground. However it doesn't update the panel until the function finishes instead of each time the text is updated.
In classic ASP I would have written the status out to either a text file or a DB and just set the page to reload on a regular basis and retrieve the information until done flag was hit and then stop the reloads. I was trying to avoid making all those call backs if I could help it. I was hoping there was a better way to do it, but if there isn't I could make just the update panel call back but I'm still not entirely sure how to turn the processing icons on and off.
Page Code
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div>
<table class="Standard">
<tr>
<td colspan="2">
<div class="Title">
Title
</div>
</td>
</tr>
<tr>
<td class="Column1">
<div style="text-align: center;">
Input Devices to Check<br />
<br />
<asp:TextBox ID="txtMachineList" runat="server" TextMode="MultiLine" Rows="12"
Width="200px"></asp:TextBox>
<asp:Button ID="btnStart" CssClass="button_blue_small" runat="server" Text="Start" OnClick="StartCheck" /><br />
<br />
</div>
<table>
<tr>
<td>
<asp:CheckBox runat="server" ID="chkOne" Text="Check 1" />
</td>
<td>
<asp:Image ID="Load1" runat="server" ImageUrl="Images/flower-loader.gif" Visible="false" />
</td>
</tr>
<tr>
<td>
<asp:CheckBox runat="server" ID="chkTwo" Text="Check 2" />
</td>
<td>
<asp:Image ID="Load2" runat="server" ImageUrl="Images/flower-loader.gif" Visible="false" />
</td>
</tr>
</table>
</td>
<td class="Column2">Status:<br />
<asp:UpdatePanel ID="StatusPanel" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="StatusPanelTimer" EventName="Tick" />
</Triggers>
<ContentTemplate>
<asp:TextBox ID="txtStatus" runat="server" Columns="300" Enabled="True" ReadOnly="True"
Width="800px" TextMode="MultiLine" Rows="35"></asp:TextBox>
<asp:Timer ID="StatusPanelTimer" runat="server" Interval="1000" OnTick="StatusTimer_Tick"></asp:Timer>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
Code Behind
protected void Page_Load(object sender, EventArgs e)
{
}
protected void StartCheck(object sender,EventArgs e)
{
Load1.Visible = true;
Load2.Visible = true;
txtStatus.Text = "Test 1";
System.Threading.Thread.Sleep(3000);
txtStatus.Text += "Test 2";
System.Threading.Thread.Sleep(3000);
txtStatus.Text += "Test 3";
System.Threading.Thread.Sleep(3000);
Load1.Visible = false;
Load2.Visible = false;
}
protected void StatusTimer_Tick(object sender, EventArgs e)
{
StatusPanel.Update();
}
So it seems the problem is in your "Start" button's function.
If you just add:
txtStatus.Text += "Tick\n";
to your tick event, you can see that your page is updating.
The problem is that After you click the button, the page doesn't receive a response until the StartCheck function finishes (Even the ticking stops).
I have 2 textboxes on an Asp.net(with c#) page and I cannot see this fields from cs class.
In aspx:
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<ajaxToolkit:ToolkitScriptManager runat="server"></ajaxToolkit:ToolkitScriptManager>
<div>
<table>
<tr>
<td style="width:40%"> <asp:Label ID="lblFullname" runat="server" Text="Fullname" ></asp:Label></td>
<td style="width:20%"> </td>
<td style="width:40%">
<asp:TextBox ID="txtFullname" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width:40%"> <asp:Label ID="lblBirthDate" runat="server" Text="BirthDate" ></asp:Label></td>
<td style="width:20%"> </td>
<td style="width:40%">
<asp:TextBox ID="txtBirthDate" runat="server" Text="" ></asp:TextBox>
<ajaxToolkit:MaskedEditExtender ID="MaskedEditExtenderBirthDate" TargetControlID="txtBirthDate" runat="server"
UserDateFormat="DayMonthYear" Mask="99/99/9999" MaskType="Date" ></ajaxToolkit:MaskedEditExtender>
</td>
</tr>
<tr><td colspan="3" style="float:right"><asp:Button Text ="Save" runat="server" ID="btnSave" OnClick="btnSave_Click"/> </td></tr>
</table>
</div>
And I am trying to get value from the txtFullname.I try txtFullname.Text and this.txtFullname but the application cannot see this values .
Can somebody how can I get the value for that textbox?
Please check if you have specified the codebehind file name correctly.
This could be one of the issues for not getting the control name
inside the code file.
If that isn't working for you, please use the below code for reference.
You have not included your "Register" directive. So, I took to privilege to give my own.
Change your markup to:
<%# Page Title="Home Page" Language="vb" MasterPageFile="~/Site.Master" AutoEventWireup="false"
CodeBehind="Default.aspx.vb" Inherits="WebApplication2._Default" %>
<%# Register TagPrefix="asp" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit" %>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="Server" />
<div>
<table>
<tr>
<td style="width: 40%">
<asp:Label ID="lblFullname" runat="server" Text="Fullname"></asp:Label>
</td>
<td style="width: 20%">
</td>
<td style="width: 40%">
<asp:TextBox ID="txtFullname" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 40%">
<asp:Label ID="lblBirthDate" runat="server" Text="BirthDate"></asp:Label>
</td>
<td style="width: 20%">
</td>
<td style="width: 40%">
<asp:TextBox ID="txtBirthDate" runat="server" Text=""></asp:TextBox>
<asp:MaskedEditExtender id="MaskedEditExtenderBirthDate" targetcontrolid="txtBirthDate"
runat="server" userdateformat="DayMonthYear" mask="99/99/9999" masktype="Date"></asp:MaskedEditExtender>
</td>
</tr>
<tr>
<td colspan="3" style="float: right">
<asp:Button Text="Save" runat="server" ID="btnSave" OnClick="btnSave_Click" />
</td>
</tr>
</table>
</div>
</asp:Content>
This code has been tested and is working.
The table tag is missing runat="server" attribute. Add it in the tag. You should be able to see the fields in cs file
Are you trying in master page or the page file ? It should work with runat="server"
You code is showing that you are using the content page which must use the master page. so you should check following things to resolve this issue.
You page must contain the Page directive similar to following one. <%# Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
Codebehind file name must be correct like page Default.aspx and Default.aspx.cs
You must use runat="server" to make control accessible at server side.
i have a serious problem.
I have a combobox in a webform. everything works fine locally. When the project is published i can't click on the combobox to display the various items. It more or less looks like a basic textbox....
This is my code:
<html>
<head>
<title></title>
<style id="Style1" type="text/css" runat="server">
td
{
vertical-align: top;
}
input.RadUploadSubmit
{
margin-top: 20px;
}
#RadUpload1
{
width: 355px;
}
</style>
<script type="text/javascript">
function CloseWindow() {
var oManager = GetRadWindowManager();
var oWnd = oManager.GetWindowByName("RadWindow1");
oWnd.Close();
}
function GetRadWindow() {
var oWindow = null;
if (window.radWindow) oWindow = window.radWindow;
else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
return oWindow;
}
function CloseDialog() {
GetRadWindow().close();
return true;
}
</script>
</head>
<body>
<form runat="server" id="Form1">
<%--method="post" enctype="multipart/form-data"--%>
<div id="formulaire">
<center>
Ticket : <b>
<asp:Label ID="TicketFamille" runat="server"></asp:Label></b></center>
<asp:Label runat="server" ID="lblERROR" Visible="false"></asp:Label>
<table cellpadding="5px" cellspacing="2px">
<tr>
<td width="200px" align='right'>
<asp:Label ID="lblTitre" runat="server" Text="Titre"></asp:Label>
:
</td>
<td>
<telerik:RadTextBox ID="txtTitre" runat="server" Skin="Telerik" Width="250">
</telerik:RadTextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*"
ForeColor="Red" ControlToValidate="txtTitre" ValidationGroup="validationincident"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align='right'>
<asp:Label ID="lblCategorie" runat="server" Text="Concerne : "></asp:Label>
</td>
<td>
<asp:RadioButtonList ID="RadioButtonList1" runat="server" AppendDataBoundItems="true"
OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged" AutoPostBack="true">
<asp:ListItem Selected="True" Value="1">Projet</asp:ListItem>
<asp:ListItem Value="2">Sous-categorie</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td align='right'>
<asp:Label ID="lblSousCategorie" runat="server" Text="Sous Categorie :"></asp:Label>
</td>
<td>
<telerik:RadComboBox ID="cbSousCategorie" runat="server" Skin="Telerik">
</telerik:RadComboBox>
</td>
</tr>
<tr>
<td align='right'>
<asp:Label ID="lblProjet" runat="server" Text="Projet : "></asp:Label>
</td>
<td>
<telerik:RadComboBox ID="cbProjet" runat="server" DataTextField="nomProjet" DataValueField="idProjet"
Skin="Telerik">
</telerik:RadComboBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="*"
ForeColor="Red" ControlToValidate="cbProjet" ValidationGroup="validationincident"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align='right'>
<asp:Label ID="lblDescription" runat="server" Text="Description : "></asp:Label>
</td>
<td>
<telerik:RadTextBox ID="txtDescription" runat="server" TextMode="MultiLine" Width="250"
Height="100" Skin="Telerik">
</telerik:RadTextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="*"
ForeColor="Red" ControlToValidate="txtDescription" ValidationGroup="validationincident"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align='right'>
Joindre un fichier :
</td>
<td>
<br />
<telerik:RadUpload ID="RadUpload1" runat="server" MaxFileInputsCount="5" Skin="Telerik">
<Localization Add="Ajouter" Clear="Vider" Delete="Supprimer" Select="Parcourir" />
</telerik:RadUpload>
<br />
<asp:Repeater ID="reportResults" runat="server" Visible="False">
<HeaderTemplate>
Fichiers attachés:<br />
</HeaderTemplate>
<ItemTemplate>
'<%#DataBinder.Eval(Container.DataItem, "FileName")%>' ( '<%#DataBinder.Eval(Container.DataItem, "ContentLength").ToString() + " bytes"%>'
)<br />
</ItemTemplate>
</asp:Repeater>
<%--<asp:Button ID="buttonSubmit" CssClass="RadUploadSubmit" OnClick="buttonSubmit_Click"
runat="server" Text="Joindre le fichier" />--%>
<br />
<%--<asp:Label ID="labelNoResults" runat="server" Visible="True">Pas de fichier joint pour le moment</asp:Label>--%>
<br />
</td>
</tr>
</table>
<asp:HiddenField runat="server" ID="HiddenFieldIdContact" />
<center><asp:Button ID="Button1" runat="server" Text="Soumettre ce ticket" OnClick="Button1_Click"
OnClientClick="if(Page_ClientValidate()) CloseDialog()" UseSubmitBehavior="false"
ValidationGroup="validationincident" /></center>
</div>
<center>
<telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
</telerik:RadScriptManager>
</center>
</form>
</body>
</html>
Thanks again for your help !!!
Have all the required DLL's or in your website BIN folder?
I think we have the same scenario, But I used Devexpress.
I don't know if is a bug on VS studio, but I have to manually add all the DLL's I used on my project BIN folder and upload it to production server.
Hope this help you!
It is possible that you have hit one of the famous ( won't fix :) ) IE limitations - 31 stylesheets per page and 4095 selectors per file.
http://blogs.telerik.com/aspnetmvcteam/posts/10-05-03/internet-explorer-css-limits.aspx
I'd recommend that you see if the problem exists in FF or Chrome.
Here you can find a test page, demonstrating the problem in IE.
http://demos.telerik.com/testcases/BrokenTheme.aspx
In the first case, you can try to combine the files as explained here:
http://www.telerik.com/community/forums/aspnet-ajax/general-discussions/custom-skin-asp-net-theme-ie-31-style-sheet-limit.aspx
This is just an assumption of course :) Normally, it is not easy to guess what happens in such scenario.
If your combo box works in dev, but not in production (or other environment), I think your problem is the data source.
you can confirm this by hardcoding the values for the combo box and seeing if it is then clickable in production.
Hello Dear Arnaud Adigard, if you code works fine locally then there show be a server problem where you are trying to deploy it. May be some file is missing or any other problem. It's generally not your cade problem because it's fine. :)
Check web config and make sure debug mode is False once it is deploy to IIS.
<compilation debug="false" strict="false" explicit="true">
<assemblies>
</assemblies>
</compilation>
Here's a my Default.aspx page (with unnecessary details excised):
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div id="login">
<!-- a bunch of markup has been removed, so this html will appear wrong and not valid, but it actually is -->
<table align="center" width="80%" cellpadding="0" cellspacing="0" class="loginBg">
<tr>
<td colspan="2"><img src="images/Login_top.jpg" /></td>
</tr>
<asp:Panel runat="server" ID="pnlLoginIn">
<tr>
<td style="padding-left:20px;">Username</td>
<td style="padding-right:15px;" align="right"><asp:TextBox id="txtUsername" runat="server" /></td>
<asp:RequiredFieldValidator runat="server" ID="rfvUserName" ErrorMessage="*" ControlToValidate="txtUsername" ValidationGroup="credentials" Display="Dynamic" />
</tr>
<tr>
<td style="padding-left:20px;">Password</td>
<td style="padding-right:15px;" align="right"><asp:TextBox ID="txtPassword" TextMode="Password" runat="server" /></td>
<asp:RequiredFieldValidator runat="server" ID="rfvPassword" ErrorMessage="*" ControlToValidate="txtPassword" ValidationGroup="credentials" Display="Dynamic" />
</tr>
<!-- BUT THE PANEL IS HERE?! -->
<asp:Panel ID="pnlInvalidCredentials" runat="server">
<tr>
<td colspan="2" align="center" style="color: Red;"><asp:Literal runat="server" ID="litInvalidCredentials" Text="Invalid Username or Password" />
</td>
</tr>
</asp:Panel>
<!-- more code has been removed down here...I just left the block commented in where the pnlInvalidCredential lives -->
</asp:Content>
Here's the code-behind (with unnecessary details excised):
namespace webapp
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
(webapp.MasterPages.MasterPage)Page.Master).headerImage = "default";
this.Master.headerImage = "default";
if (!Page.IsPostBack)
{
this.pnlInvalidCredentials.Visible = false; // error is here
this.BindPressRoomItem();
}
}
}
}
This page/code-behind is top level, it's not it any folder or anything. Also this project is an ASP.NET Web Application that is borrowing code from a legacy web site project. I didn't "Add Existing" to any files, all files were "Add New" to prevent compatibility problems. Tried this, didn't work.
In the code-behind, every attempt to manipulate items declared in the aspx page results in an error like:
'_Default' does not contain a definition for 'pnlInvalidCredentials'
or
The name 'txtUsername' does not exist in this context.
Since I refreshed this page you've removed the line with the page directive at the top of your html file, but it looked like you maybe need to include the namespace.
Try:
Inherits="webapp._Default" instead of Inherits="_Default"
Try changing the "CodeBehind" attribute in your Default.aspx page to "CodeFile."
If this is a web application, sometimes it happens that the *.designer.cs file is not updated with your latest changes.
Try this:
Remove the panel (just cut it)
Save
Undo
Save again (this will regenerate the *.designer.cs file)
Rebuild
Edit:
Other possibilities that will fail the regeneration of the *.designer.cs file are syntax errors such as missing end tags in your aspx pages.
I just had the same problem. What fixed it for me was:
in my code behind file, the class was defined as 'Public class'. Changing this to 'Partial Class', then clicking 'Convert to Web Application' regenerated the 'Designer' file and fixed the problem.
I installed the Asp.net Ajax toolkit. In my site I use the NummericUpDown from that toolkit.
Now, I want that a label changes when the NummericUpDown Textboxes changes. I try to use JavaScript for this, but I always get the following error:
'ASP.orders_aspx' does not contain a definition for 'changeAmount' and no extension method 'changeAmount' accepting a first argument of type 'ASP.orders_aspx' could be found (are you missing a using directive or an assembly reference?)
This is my code:
<%# Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
CodeFile="orders.aspx.cs" Inherits="orders" Title="the BookStore" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<script type="text/javascript">
function changeAmount()
{
var amount = document.getElementById("txtCount");
var total = 10 * amount.value;
document.getElementById("lblPrice").value = total;
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<ajaxToolkit:ToolkitScriptManager runat="Server" EnablePartialRendering="true" ID="ScriptManager1" />
<h1 id="H1" runat="server">
Bestellen</h1>
<asp:Panel ID="pnlZoeken" runat="server" Visible="true">
<asp:ObjectDataSource ID="objdsSelectedBooks" runat="server" OnSelecting="objdsSelectedBooks_Selecting"
TypeName="DAL.BooksDAL"></asp:ObjectDataSource>
<h3>
Overzicht van het gekozen boek</h3>
<asp:FormView ID="fvBestelBoek" runat="server" Width="650">
<ItemTemplate>
<h3>
Aantal boeken bestellen</h3>
<table width="650">
<tr class="txtBox">
<td>
Boek
</td>
<td>
Prijs
</td>
<td>
Aantal
</td>
<td>
Korting
</td>
<td>
Totale Prijs
</td>
</tr>
<tr>
<td>
<%# Eval("TITLE") %>
</td>
<td>
<asp:Label ID="lblPrice" runat="server" Text='<%# Eval("PRICE") %>' />
</td>
<td>
<asp:TextBox OnTextChanged="changeAmount()" ID="txtCount" runat="server"></asp:TextBox>
<ajaxToolkit:NumericUpDownExtender ID="NumericUpDownExtender1" runat="server" TargetControlID="txtCount"
Width="50" Minimum="1" ServiceDownMethod="" ServiceUpMethod="" />
</td>
<td>
-
</td>
<td>
<asp:Label ID="lblAmount" runat="server" />
</td>
</tr>
</table>
</ItemTemplate>
</asp:FormView>
<asp:Button ID="btnBestel" runat="server" CssClass="btn" Text="Bestel" OnClick="btnBestel_Click1" />
<asp:Button ID="btnReChoose" runat="server" CssClass="btnDelete" Text="Kies een ander boek"
OnClick="btnRechoose_Click" />
</asp:Panel>
</asp:Content>
Does anyone know the answer?
Thanks a lot, Vincent
You're trying to assign a client-side method to the OnTextChanged event, which is a server-side event.
Also, your javascript is referencing the server id of the label and textbox. The WinForms engine appends characters to this depending where the control is nested. Use <%=myControl.ClientID%> to get around this.
You need to use some pure Javascript for this:
window.onload=function(){
//assign client method to textbox
document.getElementById('<%=txtCount.ClientID%>').onChange = function(){
var amount = document.getElementById('<%=txtCount.ClientID%>');
var total = 10 * amount.value;
document.getElementById('<%=lblPrice.ClientID%>').value = total;
}
}
Place that on your page instead of your current Javascript and get rid of the OnTextChanged="changeAmount()" attribute.
You set OnTextChanged for TextBox. It is refer to server method, that is fired on PostBack.
If you want to handle Up and Down events in background by method on your Page, you have to set
properties ServiceUpPath and ServiceUpMethod for NumericUpDown tag.
If you want to handle client events - set custom Up and Down buttons and set property OnClientClick to them.
See
http://www.asp.net/AJAX/AjaxControlToolkit/Samples/NumericUpDown/NumericUpDown.aspx