473,847 Members | 1,480 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to get data from client-side assembly in one step?

I can get data from a client-side assembly to the server in two manual
steps, but I need to be able to do it in one step.

Step 1:
The user presses the manually coded "Step 1" button, which calls the
JavaScript function.
The function copies the data into a server textbox control.

Step 2:
The user presses the VS generated "Step 2" button, which calls the
server-side event handler "Button1_Click" .
Button1_Click can read and thus process the contents of the server control.
<body MS_POSITIONING= "GridLayout ">

<OBJECT id="myControl1 " height="288" width="312"
classid="Client SideAssembly.dl l#ClientSideAss embly.myControl "
name="myControl 1" VIEWASTEXT>
</OBJECT>

<form id="Form1" name="Form1" method="post" runat="server" VIEWASTEXT>
<input onclick="doScri pt();" type="button" value="step 1" style="WIDTH:
100px; HEIGHT: 24px">
<asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 11px; POSITION:
absolute; TOP: 400px"
runat="server" Width="359px"></asp:TextBox>
<asp:Button id="Button1" style="Z-INDEX: 103; LEFT: 375px; POSITION:
absolute; TOP: 400px"
runat="server" Text="Step 2" Width="82px"></asp:Button>
</form>

<script language="javas cript">
function doScript()
{
// This line successfully uses the client-side assembly
// to read text from a client file and assign it to a server control,
// but this doesn't trigger the TextBox1_TextCh anged event for that
server control.
Form1.TextBox1. value = myControl1.File Text;
}
</script>

</body>
Nov 17 '05 #1
1 2687
You have to connect both a client event handler and a server event
handler to the same button.
I recently implemented this functionality. Below is a test harness
that demonstrates how to pass a value from client to server using
either a server control (asp:button) or a client control
(HtmlInputButto n)

(HTML)
*************** *************** *************** ***********
<HTML>
<HEAD>
<title>ClientSe rverCrossover</title>
<meta name="GENERATOR " Content="Micros oft Visual Studio 7.0">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
<script language="javas cript">
function client_func(sou rce){
document.form1. hidden1.value = source;
//document.form1. hidden1.style.c olor
}
</script>
</HEAD>
<body MS_POSITIONING= "GridLayout ">
<form id="form1" method="post" runat="server">
<input ID="hidden1" runat="server" type="hidden">& nbsp;
<asp:Button id="aspButton" runat="server" style="Z-INDEX: 101;
LEFT: 43px; POSITION: absolute; TOP: 58px" Width="120px" Text="Use asp
button"></asp:Button>
<input ID="htmlInput" type="button"
onserverclick=" EitherButton_Cl ick" onclick="client _func('html
input');" runat="server" style="Z-INDEX: 102; LEFT: 210px; WIDTH:
104px; POSITION: absolute; TOP: 58px; HEIGHT: 24px" value="Use html
Input">
<asp:TextBox id="txtOutput" style="Z-INDEX: 103; LEFT: 16px;
POSITION: absolute; TOP: 116px" runat="server"
Width="333px"></asp:TextBox>
</form>
</body>

(codebehind)
*************** *************** *************** *************** ***********
//the value(text) property can be assigned from client function for
later use by server code
protected System.Web.UI.H tmlControls.Htm lInputHidden hidden1;
//the client and server event handlers are specified in HTML
protected System.Web.UI.H tmlControls.Htm lInputButton htmlInput;
//the client event handler is added in Page_Load, the server event
handler in OnInit
protected System.Web.UI.W ebControls.Butt on aspButton;
protected System.Web.UI.W ebControls.Text Box txtOutput;

private void Page_Load(objec t sender, System.EventArg s e)
{
//if the control is a webcontrol (asp:) then client script event
handlers
//must be added at runtime
if (!IsPostBack)
aspButton.Attri butes.Add("oncl ick", "client_func('a sp button')");
}

public void EitherButton_Cl ick(object sender, System.EventArg s e)
{
//both the htmlInput and the aspButton are wired up to use this
handler on postback
txtOutput.Text = ("value passed from client to server using " +
hidden1.Value.T oString());
}

override protected void OnInit(EventArg s e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeCompo nent();
base.OnInit(e);
//add server event handler for server control
aspButton.Click += new
System.EventHan dler(this.Eithe rButton_Click);
this.Load += new System.EventHan dler(Page_Load) ;
}

- Fred W
"Jim Hammond" <jh******@posta linnovations.co m> wrote in message news:<uA******* *******@TK2MSFT NGP10.phx.gbl>. ..
I can get data from a client-side assembly to the server in two manual
steps, but I need to be able to do it in one step.

Step 1:
The user presses the manually coded "Step 1" button, which calls the
JavaScript function.
The function copies the data into a server textbox control.

Step 2:
The user presses the VS generated "Step 2" button, which calls the
server-side event handler "Button1_Click" .
Button1_Click can read and thus process the contents of the server control.
<body MS_POSITIONING= "GridLayout ">

<OBJECT id="myControl1 " height="288" width="312"
classid="Client SideAssembly.dl l#ClientSideAss embly.myControl "
name="myControl 1" VIEWASTEXT>
</OBJECT>

<form id="Form1" name="Form1" method="post" runat="server" VIEWASTEXT>
<input onclick="doScri pt();" type="button" value="step 1" style="WIDTH:
100px; HEIGHT: 24px">
<asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 11px; POSITION:
absolute; TOP: 400px"
runat="server" Width="359px"></asp:TextBox>
<asp:Button id="Button1" style="Z-INDEX: 103; LEFT: 375px; POSITION:
absolute; TOP: 400px"
runat="server" Text="Step 2" Width="82px"></asp:Button>
</form>

<script language="javas cript">
function doScript()
{
// This line successfully uses the client-side assembly
// to read text from a client file and assign it to a server control,
// but this doesn't trigger the TextBox1_TextCh anged event for that
server control.
Form1.TextBox1. value = myControl1.File Text;
}
</script>

</body>

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
4661
by: Anon Email | last post by:
Hi people, I'm learning about header files in C++. The following is code from Bartosz Milewski: // Code const int maxStack = 16; class IStack
28
3438
by: Act | last post by:
Why is it suggested to not define data members as "protected"? Thanks for help!
4
8089
by: zhimin | last post by:
Hi, I'm writing a program to send large file(100m) through dotnet using TCPListener & TCPClient, I'm sending the file with a ask and response loop: 1. Client send a flag 1 to server indicate it has data send to server. 2. Client send the buffer block size. 3. Client send the actual buffer to the server. 4. Server send a flag 1 to client indicating that the buffer has been successfully receeived. 5. The next loop until all data of the...
3
2665
by: Marc Gravell | last post by:
Kind of an open question on best-practice for smart-client design. I'd really appreciate anyones views (preferably with reasoning, but I'll take what I get...). Or if anybody has any useful links on the subject? (and yes, I have already googled it at length, but still no strong decision) ============= After a long stint of pure-desktop / pure-server applications, I'm currently working on a number of smart-client projects in C# using...
4
4235
by: Schwarty | last post by:
I hope I posted this to the correct group. If not, please let me know and I will get it posted in the correct section. I have a web application developed in ASP.NET using C# for the code behind. I need to be able to print shipping labels from a web page within this application. The shipping label data is pulled from a 3rd party application and comes in binary format specific for certain brands of label printers. I have a class library...
9
3612
by: Macca | last post by:
Hi, I have a synchronous socket server which my app uses to read data from clients. To test this I have a simulated client that sends 100 byte packets. I have set up the socket server so that its buffer is bigger than this. I did this expecting the data to be read in one pass.
2
6885
by: Macca | last post by:
My app has an asynchronous socket server. It will have 20 clients connected to the server. Each client sends data every 500 millisecondsThe Connections once established will not be closed unless there is a problem with the connection. I need to know which client has sent the incoming data as each client has its own buffer on my "server" app. I am using the standard asynch socket code from MSDN to listen for connections and they...
0
4703
by: Macca | last post by:
Hi, I am writing an asychronous socket server to handle 20+ simulataneous connections. I have used the example in MSDN as a base. The code is shown at end of question. Each connection has a number of different types of data coming in. I have a databuffer for each type of data coming in.
17
3557
by: Timothy.Rybak | last post by:
Hello all, This is my first attempt at an application, so kid gloves are appreciated. I need to make a very simple form that only has a few elements. One is TraceCode - a text field that is populated when a user scans a label. The other is ScanDate - a date/time field that should equal the date/time of the scan (e.g. 7/31/2006 5:00:00 AM).
1
4173
by: quddusaliquddus | last post by:
Hi :D, I am sending data to server via TCP IP Connection. I am using a continuous loop at the server end - that accepts new clients and while streams can be read, it reads data stream. The data is sent from the client with 2 leading bytes of data that represent the size of the packet of data sent and type of data. My question is: how do I retrieve the size of the data packet and then check that this amount of data has been...
0
9889
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9732
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10988
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10344
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9487
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7886
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5914
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4536
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4126
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.