Login  
Search All Forums
Dart Home | PowerWEB LiveControls for ASP.NET | Custom Development Reply | PowerWEB LiveControls for ASP.NET Topics | Forums   
AuthorForum: PowerWEB LiveControls for ASP.NET
Topic: pass variables between js and asp.net
administrator
weiner@parrotsoftware.com

From: West Bloomfield, MI USA
Posts: 55
Member Since: 12/12/05
posted November 6, 2008 9:31 AM

I have a general question about passing variable values between javascript and livecontrols. The following code will illustrate setting a livecontrol value from javascript. Why do I get different values in each textbox when they were both set to exactly the same value?

Form Code:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<%@ Register assembly="Dart.PowerWEB.LiveControls" namespace="Dart.PowerWEB.LiveControls" tagprefix="cc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title>Untitled Page</title>
</head>
<body>
  <form id="form1" runat="server">
  <div>
    <cc1:LiveTextBox ID="LiveTextBox1" runat="server">5</cc1:LiveTextBox>
    <br />
    <cc1:LiveButton ID="LiveButton1" runat="server"
      Text="Add 10 to the contents of text box" />
    <br />
    <br />
    <cc1:LiveTextBox ID="LiveTextBox2" runat="server">0</cc1:LiveTextBox>
  </div>
  </form>
</body>
</html>

Code Behind:
Partial Class _Default
  Inherits System.Web.UI.Page

  Protected Sub LiveButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LiveButton1.Click
    Dim t As Integer = 10
    LiveButton1.BufferedScript.Write("(document.getElementById('" + LiveTextBox1.ClientID + "').value='5');")
    LiveTextBox1.Text = (t + CInt(LiveTextBox1.Text)).ToString
    LiveTextBox2.Text = (t + CInt(LiveTextBox1.Text)).ToString

  End Sub

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If Not Page.IsPostBack Then


    End If

  End Sub
End Class
Jamie Powell (Admin)

From: Rome, NY USA
Posts: 448
Member Since: 03/13/07

Extra Support Options
Custom Application Development

posted November 6, 2008 9:38 AM

Hello, this issue needs to be handled directly through our administrative procedures prior to response. Please contact sales@dart.com directly regarding this issue. Thank you.
administrator
weiner@parrotsoftware.com

From: West Bloomfield, MI USA
Posts: 55
Member Since: 12/12/05
posted November 8, 2008 11:43 AM

I have nenewed my subscription. Can you take a look at this?
K M Drake



From: Utica, NY USA
Posts: 3406
Member Since: 07/14/00
posted November 10, 2008 10:21 AM

Hi,
I am going to assume that you meant to set *LiveTextBox2* to 5 in the client script, and then set it to t + *its* value in the server-side code.
Otherwise, your post does not make much sense.

The problem here is that the value of LiveTextBox2 is set twice in the same postback, so the same response sets the value twice.

First it is set to 5, then to 0+10 = 10 (not 5+10, since it will not be set to 5 until this very response).
The control shows the value is was last set to (10).

Hope it helps,
-ken
Reply | PowerWEB LiveControls for ASP.NET Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX