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

Discussion in '.NET' started by sharpfun23, Aug 29, 2006.

  1. sharpfun23

    sharpfun23

    Joined:
    Aug 29, 2006
    Messages:
    1
    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: Aug 29, 2006
    sharpfun23, Aug 29, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TW9l?=
    Replies:
    1
    Views:
    564
    Bruce Barker
    May 12, 2005
  2. =?Utf-8?B?dGVycnlyZXk=?=

    IE hosted winform control not fully working

    =?Utf-8?B?dGVycnlyZXk=?=, Aug 20, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    467
    =?Utf-8?B?dGVycnlyZXk=?=
    Aug 20, 2005
  3. jwinkler2083233@gmail.com
    Replies:
    0
    Views:
    412
    jwinkler2083233@gmail.com
    Feb 10, 2006
  4. Ferruccio Bongianni

    MDI winform hosted in internet explorer

    Ferruccio Bongianni, Jul 17, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    561
    Ferruccio Bongianni
    Jul 17, 2007
  5. Scott Leonard

    Security Exception - Winform usercontrol hosted in ASP.NET

    Scott Leonard, Dec 3, 2004, in forum: ASP .Net Security
    Replies:
    2
    Views:
    256
    Scott Leonard
    Dec 22, 2004
Loading...

Share This Page