Winform user control hosted in IE: set property and call public member issues

Joined
Aug 29, 2006
Messages
1
Reaction score
0
I have a Winform user control hosted in IE. the control and asp.net page wrote in .net 2.0.

I have adjusted the trust level. the control looks Ok on the asp.net page.

the problem is on the page I have a button to trigger a Javascript function. the Javascript will pass a value to Winform control by using property defined in winform user control. but that value never been set properly. also I tried to call a control's public method from Javascript function on the page. I got a Javascript error :" Object doesn't support the property or method".

anyone got idea what's going on, please help!
thank

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&nbsp;

<input id="Text1" type="text" /></p>

<p>output<input id="Text2" type="text" /></p>
<p>
<input id="Button1" style="left: 0px; position: relative" 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!";
}
}
}
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,783
Latest member
RickeyDort

Latest Threads

Top