Javascript error - calculating time

I'm using Visual Web Developer with oBout grid templates (in C#), and need a javascript to produce a calculated field for a timesheet. According to oBout Knowledge Base, I need all all three fields as templates within the grid. Here's the reference page: http://www.obout.com/grid/KnowledgeBase.aspx?id=86

I've used the example and edited it to fit my needs. When testing the page, I get a runtime error: 'txtTimeIn' is undefined. Can anyone see my error? I'm going round in circles... It my be overkill, but I'll list my full code (all in one page):

 
1    <%@ Page Language="C#" %>
2    <%@ Register TagPrefix="obout" Namespace="Obout.Grid" Assembly="obout_Grid_NET" %>
3    
4    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5    
6    <script runat="server" type="text/C#">
7        protected void Page_Load(object sender, EventArgs e)
8        {
9            Label1.Text = User.Identity.Name;
10           Label2.Text = DateTime.Now.ToShortDateString();
11       }
12   </script>
13   <html>
14   	<head>
15   	<script type="text/javascript" language="javascript" >
16   	    function calculateMins() {
17   	        var TimeIn = document.getElementById('txtTimeIn').value;
18   	        var TimeOut = document.getElementById('txtTimeOut').value;
19   	        var Mins = parseFloat(document.getElementById('txtMins').value);
20   	        vMins.value = vTimeOut - vTimeIn;
21   	    } 
22       </script>	
23   	</head>
24   	<body>	
25   		<form runat="server">
26            <div style="position: absolute; z-index: auto; width: 750px;">   
27               <asp:GridView ID="GridView3" runat="server" AutoGenerateColumns="False" 
28                        DataKeyNames="EmpID" DataSourceID="SqlDataSource3" ShowHeader="True" 
29                        SelectedIndex="0" EditIndex="0" BorderStyle="None" GridLines="None" 
30                    Width="200px">
31                   <Columns>
32                       <asp:BoundField DataField="EmpID" HeaderText="EmpID" 
33                           SortExpression="EmpID" />
34                       <asp:BoundField DataField="Mins" HeaderText="Mins" ReadOnly="True" 
35                           SortExpression="Mins" />
36                       <asp:BoundField DataField="Hrs" HeaderText="Hrs" ReadOnly="True" 
37                           SortExpression="Hrs" DataFormatString="{0:F2}" />
38                   </Columns>
39               </asp:GridView> 
40            </div> 
41            <asp:LoginName ID="LoginName1" runat="server" Visible="False" />        
42   	 <br />
43   		<obout:Grid id="grid1" runat="server" AutoGenerateColumns="False"
44   			FolderStyle="../../obout/Grid/styles/style_6" AllowFiltering="True" 
45               DataSourceID="SqlDataSource1" ShowColumnsFooter="True" >
46   			<Columns>
47   				<obout:Column ID="Column1" HeaderText="EDIT" AllowEdit="true" AllowDelete="true" Width="125" runat="server" />
48   			    <obout:Column ID="Column2" DataField="TimeID" Visible="false" ReadOnly="true" HeaderText="Time ID" Width="50" runat="server" AllowDelete="True" />
49   				<obout:Column ID="Column3" DataField="EmplID" HeaderText="ID" Width="60" runat="server" ReadOnly="True" AllowDelete="True" />
50   				<obout:Column ID="Column4" DataField="Date" HeaderText="Date" Width="100" runat="server" DataFormatString="{0:d}" AllowEdit="True" AllowDelete="True" />		
51   				<obout:Column ID="Column5" DataField="TimeIn" HeaderText="TimeIn" Width="75" runat="server" AllowDelete="True" AllowEdit="True" >
52   				    <TemplateSettings EditTemplateId="TimeInTemplate" />
53   				</obout:Column>
54   				<obout:Column ID="Column6" DataField="TimeOut" HeaderText="TimeOut" Width="75" runat="server" AllowDelete="True" AllowEdit="True" >
55   				    <TemplateSettings EditTemplateId="TimeOutCodeTemplate" />
56   				</obout:Column>
57   				<obout:Column ID="Column7" DataField="Mins" HeaderText="Mins" Width="75" runat="server" AllowDelete="True" AllowEdit="True" >
58   				    <TemplateSettings EditTemplateId="MinsCodeTemplate" />
59   				</obout:Column>				
60   				<obout:Column ID="Column8" DataField="WIP" HeaderText="WIP" Width="75" runat="server" AllowDelete="True" AllowEdit="True" />
61   				<obout:Column ID="Column9" DataField="WO" HeaderText="WO" Width="125" runat="server" AllowDelete="True" AllowEdit="True" />
62   				<obout:Column ID="Column10" DataField="ItemNo" HeaderText="ItemNo" Width="75" runat="server" AllowDelete="True" AllowEdit="True" />
63   				<obout:Column ID="Column11" DataField="Task" HeaderText="Task" Width="75" 
64                       runat="server" AllowDelete="True" AllowEdit="True" >	
65                       <TemplateSettings EditTemplateId="TaskCodeTemplate"></TemplateSettings>
66                   </obout:Column>
67   				<obout:Column DataField="Task" HeaderText="Task" Width="75" runat="server" AllowDelete="True" AllowEdit="True" >
68   				    <TemplateSettings EditTemplateId="TaskCodeTemplate" />
69   				</obout:Column>
70   				<obout:Column ID="Column12" DataField="Code" HeaderText="Code" Width="75" runat="server" AllowDelete="True" AllowEdit="True" />
71   				<obout:Column ID="Column13" HeaderText="EDIT" AllowEdit="true" AllowDelete="true" Width="125" runat="server" />
72   			</Columns>
73   					 <Templates>
74   			            <obout:GridTemplate ID="TaskCodeTemplate" runat="server"  ControlID="ddlTaskCode" ControlPropertyName="value">
75   			                <Template>
76   			                    <asp:DropDownList runat="server" ID="ddlTaskCode" DataSourceID="SqlDataSource2"
77   			                DataValueField="Code" DataTextField="Code" />
78   			                </Template> 			                  
79                           </obout:GridTemplate>
80                           <obout:GridTemplate ID="TimeInTemplate" ControlID="txtTimeIn">
81                               <Template>
82                                   <input type="txtTimeIn" onchange="calculateMins()"  />
83                               </Template>
84                           </obout:GridTemplate>
85                           <obout:GridTemplate ID="TimeOutTemplate" ControlID="txtTimeOut">
86                               <Template>
87                                   <input type="txtTimeOut" onchange="calculateMins()"  />
88                               </Template>
89                           </obout:GridTemplate>
90                           <obout:GridTemplate ID="MinsTemplate" ControlID="txtMins">
91                               <Template>
92                                   <input type="txtMins" readonly="readonly"  />
93                               </Template>
94                           </obout:GridTemplate>
95                         </Templates>
96           </obout:Grid>
97           <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
98               ConnectionString="<%$ ConnectionStrings:MAFapp %>" 
99               DeleteCommand="DELETE FROM [Time] WHERE [TimeID] = @TimeID" 
100              InsertCommand="INSERT INTO [Time] ([EmplID], [Date], [TimeIn], [TimeOut], [Mins], [WIP], [WO], [ItemNo], [Code], [Task], [Note]) VALUES (@EmplID, @Date, @TimeIn, @TimeOut, @Mins, @WIP, @WO, @ItemNo, @Code, @Task, @Note)" 
101              SelectCommand="SELECT TimeID, EmplID, Date, TimeIn, TimeOut, DATEDIFF(MI, TimeIn, TimeOut) AS Mins, WIP, WO, ItemNo, Code, Task, Note, MgrNote, DueDate FROM Time WHERE (EmplID = @Param1) AND (Date = @Param2) OR (EmplID = @Param1) AND (Date IS NULL) ORDER BY Date, TimeIn" 
102              UpdateCommand="UPDATE [Time] SET [EmplID] = @EmplID, [Date] = @Date, [TimeIn] = @TimeIn, [TimeOut] = @TimeOut, [Mins] = @Mins, [WIP] = @WIP, [WO] = @WO, [ItemNo] = @ItemNo, [Code] = @Code, [Task] = @Task, [Note] = @Note WHERE [TimeID] = @TimeID">
103              <SelectParameters>
104                  <asp:ControlParameter ControlID="GridView3" Name="Param1" 
105                      PropertyName="SelectedValue" />
106                  <asp:ControlParameter ControlID="Label2" Name="Param2" PropertyName="Text" />
107              </SelectParameters>
108              <DeleteParameters>
109                  <asp:Parameter Name="TimeID" />
110              </DeleteParameters>
111              <UpdateParameters>
112                  <asp:Parameter Name="EmplID" />
113                  <asp:Parameter Name="Date" />
114                  <asp:Parameter Name="TimeIn" />
115                  <asp:Parameter Name="TimeOut" />
116                  <asp:Parameter Name="Mins" />
117                  <asp:Parameter Name="WIP" />
118                  <asp:Parameter Name="WO" />
119                  <asp:Parameter Name="ItemNo" />
120                  <asp:Parameter Name="Code" />
121                  <asp:Parameter Name="Task" />
122                  <asp:Parameter Name="Note" />
123                  <asp:Parameter Name="TimeID" />
124              </UpdateParameters>
125              <InsertParameters>
126                  <asp:Parameter Name="EmplID" />
127                  <asp:Parameter Name="Date" />
128                  <asp:Parameter Name="TimeIn" />
129                  <asp:Parameter Name="TimeOut" />
130                  <asp:Parameter Name="Mins" />
131                  <asp:Parameter Name="WIP" />
132                  <asp:Parameter Name="WO" />
133                  <asp:Parameter Name="ItemNo" />
134                  <asp:Parameter Name="Code" />
135                  <asp:Parameter Name="Task" />
136                  <asp:Parameter Name="Note" />
137              </InsertParameters>
138          </asp:SqlDataSource>
139          <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
140              ConnectionString="<%$ ConnectionStrings:MAFapp %>" 
141              SelectCommand="SELECT DISTINCT TaskCodes.Code FROM Employees CROSS JOIN TaskCodes ORDER BY TaskCodes.Code">
142              </asp:SqlDataSource>		
143          <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
144              ConnectionString="<%$ ConnectionStrings:MAFapp %>" 
145              SelectCommand="SELECT Time.EmplID AS EmpID, SUM(DATEDIFF(MI, Time.TimeIn, Time.TimeOut)) AS Mins, SUM(DATEDIFF(MI, Time.TimeIn, Time.TimeOut) / 60.0) AS Hrs, Employees.EmpName, Time.Date FROM Time INNER JOIN Employees ON Time.EmplID = Employees.EmplID GROUP BY Time.EmplID, Employees.EmpName, Time.Date HAVING (Employees.EmpName = @Param1) AND (Time.Date = @Param2)">
146              <SelectParameters>
147                  <asp:ControlParameter ControlID="Label1" Name="Param1" PropertyName="Text" />
148                  <asp:ControlParameter ControlID="Label2" Name="Param2" PropertyName="Text" />
149              </SelectParameters>
150          </asp:SqlDataSource>		
151  		<asp:SqlDataSource ID="SqlDataSource4" runat="server" 
152              ConnectionString="<%$ ConnectionStrings:MAFapp %>" 
153              SelectCommand="SELECT EmplID FROM Employees WHERE (EmpName = @Param1)">
154              <SelectParameters>
155                  <asp:ControlParameter ControlID="Label1" Name="Param1" PropertyName="Text" />
156              </SelectParameters>
157          </asp:SqlDataSource>
158  		<br />
159  		</form>
160  	</body>
161  </html>

Thank you for any assistance,

JC


  

 

0
jct
4/29/2009 9:30:23 PM
asp.net.client-side 24353 articles. 1 followers. Follow

11 Replies
1324 Views

Similar Articles

[PageSpeed] 2

Hi,

Firstly i've never used this gridview before, but i shall try to help based on what i see

jct.maf:
<obout:GridTemplate ID="TimeInTemplate" ControlID="txtTimeIn"> 81 <Template> 82 <input type="txtTimeIn" onchange="calculateMins()" /> 83 </Template> 84 </obout:GridTemplate>

in this case, do you need to add the runat="Server" for txtTimeIn and also there is no type called txtTimeIn i.e <input type="text" id="txtTimeIn" onchange="calculateMins()" runat="Server" />, same for the other 2 textboxes

jct.maf:
16 function calculateMins() { 17 var TimeIn = document.getElementById('txtTimeIn').value; 18 var TimeOut = document.getElementById('txtTimeOut').value; 19 var Mins = parseFloat(document.getElementById('txtMins').value); 20 vMins.value = vTimeOut - vTimeIn; 21 }
 

this will also most probably fail, because of the way you have defined, there is multiple txttimein, timeout etc..

try the first fix, that should get you up and running, then lets see if you can figure out how to fix part 2 on your own :)

0
kwanann
4/29/2009 10:01:39 PM

 Well, I add runat="Server" for all 3 and got a new error message:

       Compiler Error Message: CS1012: Too many characters in character literal

 

This is what oBout's Knowledge Base provided as an example. I removed the 'parseFloat' for txtTimeIn & txtTimeOut.

Calculate the value of a column based on the values of other columns

Q: I am using the multi-record editing feature. I have three columns - 'quantity', 'price', 'total price'.
'quantity' and 'price' are editable, 'total price' is readonly. I want the 'total price' column to be
calculated automatically when 'quantity' or 'price' changes. How can I implement this functionality?

A: You need to create a template for each column. Each template will contain a textbox, the one
for 'total price' will be marked as readonly. Also, the textboxes for 'quantity' and 'price' will use the
onchange event to detect when the user performs a change. The event handler for the onchange
event will perform the needed calculation. For example:

<obout:GridTemplate ID="QuantityTemplate" ControlID="txtQuantity">
        <Template>
                <input type="txtQuantity" onchange="calculateTotal()" class="ob_gAL" />
        </Template>
</obout:GridTemplate>


<obout:GridTemplate ID="PriceTemplate" ControlID="txtPrice">
        <Template>
                <input type="txtPrice" onchange="calculateTotal()" class="ob_gAL" />
        </Template>
</obout:GridTemplate>


<obout:GridTemplate ID="TotalPriceTemplate" ControlID="txtTotalPrice">
        <Template>
                <input type="txtTotalPrice" readonly="readonly" class="ob_gAL" />
        </Template>
</obout:GridTemplate>

In JavaScript, the "calculateTotal" function needs to look like this:

function calculateTotal() {
 var quantity = parseFloat(document.getElementById('txtQuantity').value);
 var price = parseFloat(document.getElementById('txtPrice').value);
 var totalPrice = document.getElementById('txtTotalPrice');
 totalPrice.value = quantity * price;
}
0
jct
4/30/2009 12:08:44 AM

jct.maf:
      Compiler Error Message: CS1012: Too many characters in character literal
 

can show me the source for this?

 

jct.maf:
<obout:GridTemplate ID="PriceTemplate" ControlID="txtPrice">
        <Template>
                <input type="txtPrice" onchange="calculateTotal()" class="ob_gAL" />
        </Template>
</obout:GridTemplate>
 

i think the person typed wrongly, there is no input type called txtPrice. and on the gridtemplate it says controlid, input type != controlid..

 

0
kwanann
4/30/2009 12:49:53 AM

 Sure, here it is:

 Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1012: Too many characters in character literal

Source Error:

Line 40:     <script type="text/javascript" runat="server" >
Line 41:         function calculateMins() {
Line 42:             var TimeIn = document.getElementById('txtTimeIn').value;
Line 43:             var TimeOut = document.getElementById('txtTimeOut').value;
Line 44:             var Mins = parseFloat(document.getElementById('txtMins').value);
 

Source File: c:\Inetpub\wwwroot\int_WIP\depts\eng\timesheet_NEW.aspx    Line: 42

Note: TimeIn and TimeOut are formatted as DateTime fields in my SQL database, and a format string is used within the .aspx page to show time only. Also, all Time info is in a table with TimeID as the unique identifier. I tried changing the script to document.getElementByName, but that didn't work either.

0
jct
4/30/2009 3:26:43 PM

ahhh i think i found the problem

jct.maf:
<script type="text/javascript" runat="server"

take out the runat="Server" and it should work arleady. you cannot set a javascript element as runat=server

0
kwanann
4/30/2009 11:01:44 PM

 Now I have a new error, which probably has something to do with my SQL field types (referenced earlier) but I'm not sure how to fix it.

 Input string was not in a correct format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.FormatException: Input string was not in a correct format.

Source Error:


Line 11:         if (e.Row.RowType == GridRowType.DataRow)
Line 12:         {
Line 13:             totalMins = int.Parse(e.Row.Cells[5].Text) - int.Parse(e.Row.Cells[4].Text);
Line 14:         }
Line 15:         else if (e.Row.RowType == GridRowType.ColumnFooter)
 

Source File: c:\Inetpub\wwwroot\int_WIP\depts\eng\periodTimesheet_NEW.aspx    Line: 13

Stack Trace:


[FormatException: Input string was not in a correct format.]
   System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +7467367
   System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +119
   System.Int32.Parse(String s) +23
   ASP.depts_eng_periodtimesheet_new_aspx.RowDataBound(Object sender, GridRowEventArgs e) in c:\Inetpub\wwwroot\int_WIP\depts\eng\periodTimesheet_NEW.aspx:13
   Obout.Grid.Grid.OnRowDataBound(GridRowEventArgs e) +65
   Obout.Grid.Grid.CreateDataRow() +900
   Obout.Grid.Grid.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) +671
   System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +57
   System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +114
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +31
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +142
   Obout.Grid.Grid.PerformSelect() +73
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73
   System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
   System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +72
   System.Web.UI.Control.EnsureChildControls() +87
   System.Web.UI.Control.PreRenderRecursiveInternal() +44
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842

0
jct
5/1/2009 12:15:21 AM

jct.maf:
e.Row.Cells[5].Text) - int.Parse(e.Row.Cells[4].Text

what are the values inside e.Row.Cells[5].Text and 4.text?

0
kwanann
5/1/2009 1:48:42 AM

Ah, should have included that... Row[5] = TimeOut , and Row[4] = TimeIn

In the meantime, I tried something else, but it's still not working. I added a calculated column in my SQL database for minutes:

              MinsCalc (formula) = datediff(minute,[TimeIn],[TimeOut])

Then changed the script to this:

1    int mins = 0;
2    
3        public void RowDataBound(object sender, GridRowEventArgs e)
4        {
5            if (e.Row.RowType == GridRowType.DataRow)
6            {
7                mins += int.Parse(e.Row.Cells[6].Text);
8            }
9            else if (e.Row.RowType == GridRowType.ColumnFooter)
10           {
11               e.Row.Cells[1].Text = "Total:";
12               e.Row.Cells[4].Text = mins.ToString();
13           }
14       }
Trouble is, I don't know what type the DateDiff is. I'm pretty sure I need to convert it, but... In the code above, 'mins' = the calculated column (MInsCalc), and row [6] refers to that column. Here's the error message:

Input string was not in a correct format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.FormatException: Input string was not in a correct format.

Source Error:


Line 17:         if (e.Row.RowType == GridRowType.DataRow)
Line 18:         {
Line 19:             mins += Convert.ToInt16(e.Row.Cells[6].Text);
Line 20:         }
Line 21:         else if (e.Row.RowType == GridRowType.ColumnFooter)
 

Source File: c:\Inetpub\wwwroot\int_WIP\depts\eng\timesheet_NEW.aspx    Line: 19

Stack Trace:


[FormatException: Input string was not in a correct format.]
   System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +7467367
   System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +119
   System.Int16.Parse(String s, NumberStyles style, NumberFormatInfo info) +39
   System.Convert.ToInt16(String value) +63
   ASP.depts_eng_timesheet_new_aspx.RowDataBound(Object sender, GridRowEventArgs e) in c:\Inetpub\wwwroot\int_WIP\depts\eng\timesheet_NEW.aspx:19
   Obout.Grid.Grid.OnRowDataBound(GridRowEventArgs e) +65
   Obout.Grid.Grid.CreateDataRow() +900
   Obout.Grid.Grid.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) +671
   System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +57
   System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +114
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +31
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +142
   Obout.Grid.Grid.PerformSelect() +73
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73
   System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
   System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +72
   System.Web.UI.Control.EnsureChildControls() +87
   System.Web.UI.Control.PreRenderRecursiveInternal() +44
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842

 
 

0
jct
5/1/2009 9:00:21 PM

ok i understand now. what you need is this instead (3.5 code, if you using .net 2, please use gettype() to find the type and replace accordingly)

var Data = e.Row.DataItem

var TS = new Timespan((e.Row.DataItem["TimeOut"] as DateTime).Ticks - (e.Row.DataItem["TimeIn"] as DateTime).Ticks)

double totalMin =TS.TotalMinutes

 

basically what i'm trying to do is get the actual data from db instead of the string value, cast it to its appropriate type (i.e datetime), then use Timespan to get the total minutes for me

0
kwanann
5/2/2009 12:09:18 AM

 Thanks, I'll try it on Monday and let you know.

 

0
jct
5/2/2009 12:37:57 AM

 I'm getting a Runtime Error -- "expecting a )" -- wavy lines at "as"...

<script type="text/javascript" language="javascript" >
           function calculateMins()
           {
            var Data = e.Row.DataItem
            var TS = new Timespan((e.Row.DataItem["TimeOut"] as DateTime).Ticks - (e.Row.DataItem["TimeIn"] as DateTime).Ticks)
            double totalMin =TS.TotalMinutes
           }
       </script>

0
jct
5/4/2009 11:49:15 PM
Reply:

Similar Artilces:

.Net varible into client side JavaScript
I'm need to get a variable from my web app and place its value in a JavaScript. I tried doing this with a Label but I get the HTML included. I don't think I can use the <%# %> from classic ASP? Anyone have any ideas on how they would approach this problem? tbone_stl wrote:Anyone have any ideas on how they would approach this problem? Hi, and welcome to the ASP.NET forums. It's possible to pass a variable to a javascript function. I created a small coding snippet: <%@ Page Language="C#" %>   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http...

How to write data to a file in client side using javascript or someother client side scripting language.
Hi, I would like to know how to write a data to a client side file using javascript or someother client side scripting language. The file type expected is ini file. txt file would also be appreciable. Thanks in advance.   If the site is a trusted and you are running IE then you could try http://www.w3schools.com/asp/asp_ref_filesystem.asp The Old Sewing FactoryThat twitter nonsense. You can write to the server, but not to the client's machine.  Being able to do so would be a huge security breach.When you ask a question, remember to click "mark as answered"...

How to use client-side script(javascript) in .Net Remoting
Hi all,     It was known that SAO and Singleton object about .Net Remoting. When I Create an object in server side and hosting in IIS's virtual directory,I want to use javascript asynchronous invoking the remote object by HTTP channel, 80 port and SOAP formatter just like XMLHTTP invoking web service. My code as following, <script>  objXmlDoc = new ActiveXObject("Msxml2.DOMDocument"); objHttp = new ActiveXObject("Msxml2.XMLHTTP"); strEnvelope = ?? objHttp.onreadystatechange = function() { ......  }    szUrl = &...

javascript client side validation at the time of image upload
Hi  everybody, i want javascript code for validating the image upload file ,it will accept only .gif and JPEG images only not every file.   Can anybody help me i will appriciate great. Thanks Krishnamurthy CKrishnamurthy CConsultant,Holmdel Consulting,krishnamurthy@holmdelconsulting.comwww.holmdelconsulting.com Here is some code that I wrote some time back that validates the maximum size and file extensions for file uploading. It should get you started anyways. aspx file: <form id="Form1" method="post" runat="server"> Select a file ...

Perform JavaScript Client Side Confirmation from a VB.NET DataGrid
Hi, I when I delete an item from the database through a Datagrid I want to get a messagebox popingup to give me the choise to Confirm it...in case I clicked the wrong item....the way it works now it just deletes it....can any one help me with an Example I have no Idea how to do this...I found an article in C# but it didnt help me at all. here is my source code <asp:DataGrid ID="dgCustList" Runat="server" AutoGenerateColumns="False" DataKeyField="id" AlternatingItemStyle-BackColor="#F6F6F6" HeaderStyle-BackColor="#C4B58E" CellSpacing="0" CellPadding="2" GridLines="Vertical" Width="100%"...

.net validators + client-side javascript validation, EnableEventValidation=false
Scenario: 1. I have a DropDownList, with 2 listitems in the .aspx. appenddatabound=true and it is tied to a datasource (via datasourceid), autopostback=false, onchange=checkIfAddNew(this) [this is the client side onchange event]The second option on this dropdown is "Add New", and the checkIfAddNew function pops up a new window and when it returns, it adds the newly created option to the dropdown. In order for this to happen without asp.net getting mad, EnableEventValidation has to be set to false in the Page directive. In addition to this dropdownlist, there is a RequiredFieldValidator...

How to use client-side script(javascript) in DNA using .Net Remoting
Hi all,     It was known that SAO and Singleton object about .Net Remoting. When I Create an object in server side and hosting in IIS's virtual directory,I want to use javascript asynchronous invoking the remote object by HTTP channel, 80 port and SOAP formatter just like XMLHTTP invoking web service. My code as following, <script> objXmlDoc = new ActiveXObject("Msxml2.DOMDocument"); objHttp = new ActiveXObject("Msxml2.XMLHTTP"); strEnvelope = ?? objHttp.onreadystatechange = function() { ...... }   szUrl = "http://ServerNa...

In datawindow.net,access the database from client side event using javascript
In powerbuilder,for example,a datawindow has two columns:itemno,description. input an itemno,validate it.if not found from the database,return 1 to trigger itemerror event; if found,get the description of the item from the database,and fill it into the column "description". The question is how to fulfill the function in web datawindow,through web service? if so,I need an example to realize it. You will need to use AJAX or make a round trip on item change event. -- Dean Jones CEO PowerObjects http://www.powerobjects.com (612) 339-3355 Ext. 112 TeamSybase * *...

Need help converting a C#/.NET method into client-side (javascript) function
Hey Guys, I have implemented an AJAX Toolkit CalendarExtender.  I have a method 'CheckDate' in javascript (followed a tut!) that checks to see if the user selected a date > DateTime.Now(). Well, I have a few other things to check but not sure how to do them in javascript, so I'm hoping someone here can help me.  I mean, i can somewhat convert it but it'll be too mangled, I'd rather learn the right way.  I'm attaching the code and any help will be appreciated.  1 protected string CheckDateErrors(string dateGiven) 2 ...

how i can add a client side script(javascript) in run time to body tag in a page
hi every body how i can add a client side script(javascript) in run time to body tag in a page. i cant access to the body tag in my code. how i can that? thank u. The easiest way is to turn the <body> tag into a server control: <body id="body" runat="server">Then, you can simply write: body.Attributes.Add( "onload", "alert('hello');" )If you are using codebehind, you declare this body control as being of the type System.Web.UI.HtmlControls.HtmlGenericControl. Does that help you?Alister Hi SomeNewKid2, Quick question...

Client Side Javascript and Dynamic Client Ids
I have a gridview that has an edit row.  When I click on edit... It pops up a inline window with modal functionality in the css... I want to fire off a webservice to bring back data to populate the input fields on the form I created... one catch I created a tab container with panels to separate out the keyed in information... So, I found that the .net is doing this to the inputs...  <input name="ctl00$cphMainBody$tcEmployeeDetails$TabPanel1$txtFirstName" type="text" maxlength="25" id="ctl00_cphMainBody_tcEmployeeDetails_TabPanel1_txtFirstNa...

server side variables in client side javascript
I want to use an ASP.net variable in client side javascript.In regular asp I used hidden fields.what is the best way to do this in ASP.NET ?thx,Intersee my blog at www.Interdevelopments.com and check the future of open mobile widget solutions at www.glowe.org By and large, I personally still use Hidden fields to store information, that either my Javascript function or my code-behind use.  I barely use the RegisterScriptBlock method(s) and that is only for situations where I want to be really dynamic with the client side functionality.  95% of the time, I can still use a...

"extra" validation javascript causing client side error after Ajax 1.0 and toolkit install
  Hello all,  I have an existing web application project. I installed Ajax 1.0 and the Ajax control toolkit and now am experiencing client side errors.  I have compared the source returned to the browser (still have the pre-Ajax version of code running on a different server) and notice there appears to be an "extra" paragraph of script which is causing problems. This extra script appears as: <script type="text/javascript"><!--var ctl02 = document.all ? document.all["ctl02"] : document.getElementById("ctl02");ctl02.headert...

Call server side function from client side javascript
I have a javascript where I either need to call an onclick even of a server link button or I need to be able to call a server side function.   The only thing is I cant use AJAX.  Is there any way I can do this or am I spinning my wheels. Thanks!-------------Please: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue. I have a similar problem.  In my case, I would like to set a server-side session object from JavaScript.  Any suggestions?  Thanks.  Dan Sure, y...

how to call server side function from client side javascript?
Hi all, I have a image button in the update panel. I would like to call a method from server side (not from webservice) to get the variable when Onclick on the image button is invoked. Is there any way that I can able to access this function from the client script? In using the UpdatePanel, in essence, you're already doing this because there will not be a full postback.  You can make an asynchronous call to your Click method of your ImageButton.  So, what do you want to do with this "variable"?Christopher Reed"The oxen are slow, but the earth is patient."...

Web resources about - Javascript error - calculating time - asp.net.client-side

Calculating Space - Wikipedia, the free encyclopedia
Calculating Space is the title of MIT 's English translation of Konrad Zuse 's 1969 book Rechnender Raum (literally: "space that is computing"), ...

Facebook Tweaks Formula for Calculating Active Application Users
Facebook made a change to the way that it counts active users for applications starting last Friday. Now, likes and comments on stream content ...

Atomic Mass Calculating Device HD for iPad on the iTunes App Store
Read reviews, get customer ratings, see screenshots, and learn more about Atomic Mass Calculating Device HD on the App Store. Download Atomic ...

Calculating Financial Figures Video - Flickr - Photo Sharing!
Feel free to use this image just link to www.learningDSLRVideo.com

How To Channel Your Road Rage Into Cold, Calculating Road Revenge - YouTube
Subscribe to The Onion on YouTube: http://bit.ly/xzrBUA Defensive driving instructor Danny Preston says the best way to avoid conflict on the ...

Is there a magic formula for calculating super?
... the many calculators out there are giving us an accurate picture of our retirement needs? Q. Could you please tell me the formula for calculating ...

All that glitters is not gold: Calculating the small business tax break
Working out how much you can claim under the government's instant asset write off can be a complicated process.

Treasury deny any part in calculating Coalition's $10b savings hole
Australia's two most senior economic bureaucrats have effectively torpedoed Kevin Rudd's claim of a $10 billion hole in opposition costings declaring ...

Calculating a percentage in a Google spreadsheet
In the second of our continuing series of video tutorials on using data journalism tools, Fred Vallance-Jones shows you how to calculate percentages ...

Samsung Galaxy S6 and S6 Edge Sales and Samsung's Turnaround, Calculating Apple Watch Adoption Rate in ...
To read these two stories, become a member by using the sign-up below ($10/month or $100/year). Above Avalon members receive 10-12 stories about ...

Resources last updated: 11/30/2015 12:43:07 AM