User-2051989583 posted
I have a Winform user control hosted in IE. the control and asp.net page wrote in .net 2.0.
the control looks Ok on the asp.net page.
the problem is on the page I have a button to trigger a javascript function. that javascript will pass a value to Winfom control by using property defined in winform user control. but that value never been set properly. also I try to call the control's
public method from Javascript function. and I got Javascript error :" Object doesn't support the property or method".
anyone got idea what's going on please help.
here is my page
<%@ Page
Language="C#"
AutoEventWireup="true"
CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<!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>
<script language="javascript"
type="text/javascript">
function Button1_onclick() {
ct1.InputData="ABCD";
alert(ct1.Calculate("fool"));
}
</script>
</head>
<body>
<div><p>input
<input
id="Text1"
type="text"
/></p>
<p>output<input
id="Text2"
type="text"
/></p>
<p>
<input
id="Button1"
style="left: 0px; "
type="button"
value="button"
language="javascript"
onclick="return Button1_onclick()"
/>
</p>
</div>
<p>
<object
id="ct1"
ClassId="testcontrol3.dll#testcontrol.UserControl1"
height="176"
width="375"
VIEWASTEXT>
<param
name="InputData"
value="xyz"
/>
</object></p>
</body>
here are the control class:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
namespace testcontrol
{
interface api
{
string Calculate(string x);
}
public partial
class UserControl1 :
UserControl, api
{
public UserControl1():base()
{
InitializeComponent();
}
private string inputData="";
public string InputData
{
get
{
return inputData;
}
set { inputData =
value; }
}
private string outputData="";
public string OutputData
{
get
{
return outputData;
}
set
{
outputData = value;
}
}
public string Calculate(string x)
{
inputData=x;
outputData = x.Length.ToString();
return outputData;
}
private void button1_Click(object sender,
EventArgs e)
{
txbInput.Text = inputData;
txbOutput.Text = inputData + " test!";
}
}
}