Hy!
I have htmleditor (from the microsoft's samples page) embeded into my
asp.net page.
Editor generates some html code inside <div id="oDiv"></div> tags. And what
I would like to do is return oDiv.InnerHtml to my "codebehind" (C#) where I
would do additional tasks on it.
If I do postback the oDiv content is lost.
Can anyone help me how to send those data back to codebehind?
Thanks in advance.
- Samo K. 8 6831
Hi
In order to access from server, you need to add runat="Server"
<div id="oDiv" runat="Server"></div
Then in server code you can ge
oDiv.innerHtm
Bin Song, MCP
yes, that's true, but if script modifies the contents of the <div> on the
client, that content will not get posted back to the server on a postback.
You must look at how ASP.NET works. The server cannot receive any
information unless it receives it in the Querystring or Form collections. A
div is not a normal form field, so it doesn't post anything back, as does
<input type="text" ... .>. You are going to have to do some custom
programming to get it to work. If it were me, I would register a hidden
form field, and call a script function right before the page submits back to
the server. In that script function, copy the InnerHTML property of the div
to the <input type=hidden. . .> and then you can get the data in server
code.
By the way, have you checked out FreeTextBox? It's a .Net WYSIWYG Html
editor. It's used in .Text, nGallery, and I use it in my EZWeb project: http://workspaces.gotdotnet.com/ezweb.
Jeffrey Palermo
"Bin Song, MCP" <an*******@discussions.microsoft.com> wrote in message
news:0F**********************************@microsof t.com... Hi,
In order to access from server, you need to add runat="Server". <div id="oDiv" runat="Server"></div> Then in server code you can get oDiv.innerHtml
Bin Song, MCP
Thanks for your reply...
I've created the hidden field like this:
<input type="hidden" id="oHidden" runat="server">
The problem with this is that the server changes the IDs a bit and when I
look at the generated HTML the id is _ctl0_oHidden.
I fill this input with data like this: form1._ctl0_oHidden.value =
oDiv.InnerHTML;
(if I do form1.oHidden.... i get object Error exception).
And when I do postback, all I get is big nothing (value == "").
I also tried with input type=text, and the script gets the right data to
oHidden (or _ctl0_oHidden).
I'm a bit noob (as you can see) to all this stuff.
- Samo K.
"Jeffrey Palermo" <je************@yahoo.com> wrote in message
news:eH**************@TK2MSFTNGP11.phx.gbl... yes, that's true, but if script modifies the contents of the <div> on the client, that content will not get posted back to the server on a postback. You must look at how ASP.NET works. The server cannot receive any information unless it receives it in the Querystring or Form collections.
A div is not a normal form field, so it doesn't post anything back, as does <input type="text" ... .>. You are going to have to do some custom programming to get it to work. If it were me, I would register a hidden form field, and call a script function right before the page submits back
to the server. In that script function, copy the InnerHTML property of the
div to the <input type=hidden. . .> and then you can get the data in server code.
By the way, have you checked out FreeTextBox? It's a .Net WYSIWYG Html editor. It's used in .Text, nGallery, and I use it in my EZWeb project: http://workspaces.gotdotnet.com/ezweb.
Jeffrey Palermo
For your script, you can do:
document.all["<%=oHidden.ClientID%>"].value = oDiv.InnherHTML;
Make sure the hidden field is inside your server-side form.
Then (with trace turned on) look at your form collection, and you should see
that the hidden field posted some data. You're on the right track. It'll
work for you.
In your code-behind, you do have a declared field like
protected HtmlInputHidden oHidden; right?
Jeffrey Palermo
"SamoK" <sn***@wetsoftware.com> wrote in message
news:Sd******************@news.siol.net... Thanks for your reply... I've created the hidden field like this:
<input type="hidden" id="oHidden" runat="server">
The problem with this is that the server changes the IDs a bit and when I look at the generated HTML the id is _ctl0_oHidden.
I fill this input with data like this: form1._ctl0_oHidden.value = oDiv.InnerHTML; (if I do form1.oHidden.... i get object Error exception).
And when I do postback, all I get is big nothing (value == "").
I also tried with input type=text, and the script gets the right data to oHidden (or _ctl0_oHidden).
I'm a bit noob (as you can see) to all this stuff.
- Samo K.
"Jeffrey Palermo" <je************@yahoo.com> wrote in message news:eH**************@TK2MSFTNGP11.phx.gbl... yes, that's true, but if script modifies the contents of the <div> on
the client, that content will not get posted back to the server on a
postback. You must look at how ASP.NET works. The server cannot receive any information unless it receives it in the Querystring or Form
collections. A div is not a normal form field, so it doesn't post anything back, as
does <input type="text" ... .>. You are going to have to do some custom programming to get it to work. If it were me, I would register a hidden form field, and call a script function right before the page submits
back to the server. In that script function, copy the InnerHTML property of the
div to the <input type=hidden. . .> and then you can get the data in server code.
By the way, have you checked out FreeTextBox? It's a .Net WYSIWYG Html editor. It's used in .Text, nGallery, and I use it in my EZWeb project: http://workspaces.gotdotnet.com/ezweb.
Jeffrey Palermo
I've tried document.all["<%=oHidden.ClientID%>"]
but the value is undefined, thus obj.value (obj=document.all["<%....) threw
object Error exception.
As for trace... I could output something like this (despite object Error
exception) on post back:
__VIEWSTATE
_ctl0:Title
_ctl0:Customer
_ctl0:Link
_ctl0:oHidden
The code was:
foreach(string s in Request.Form.Keys)
System.Diagnostics.Trace.WriteLine(s);
But the oHidden.Value in my server code remains "".
Am I annoying? :) This annoys me for the past few days.
Samo K.
"Jeffrey Palermo" <je************@yahoo.com> wrote in message
news:ez**************@tk2msftngp13.phx.gbl... For your script, you can do: document.all["<%=oHidden.ClientID%>"].value = oDiv.InnherHTML; Make sure the hidden field is inside your server-side form. Then (with trace turned on) look at your form collection, and you should
see that the hidden field posted some data. You're on the right track. It'll work for you.
In your code-behind, you do have a declared field like protected HtmlInputHidden oHidden; right?
Jeffrey Palermo
"SamoK" <sn***@wetsoftware.com> wrote in message news:Sd******************@news.siol.net... Thanks for your reply... I've created the hidden field like this:
<input type="hidden" id="oHidden" runat="server">
The problem with this is that the server changes the IDs a bit and when
I look at the generated HTML the id is _ctl0_oHidden.
I fill this input with data like this: form1._ctl0_oHidden.value = oDiv.InnerHTML; (if I do form1.oHidden.... i get object Error exception).
And when I do postback, all I get is big nothing (value == "").
I also tried with input type=text, and the script gets the right data to oHidden (or _ctl0_oHidden).
I'm a bit noob (as you can see) to all this stuff.
- Samo K.
"Jeffrey Palermo" <je************@yahoo.com> wrote in message news:eH**************@TK2MSFTNGP11.phx.gbl... yes, that's true, but if script modifies the contents of the <div> on the client, that content will not get posted back to the server on a postback. You must look at how ASP.NET works. The server cannot receive any information unless it receives it in the Querystring or Form collections. A div is not a normal form field, so it doesn't post anything back, as does <input type="text" ... .>. You are going to have to do some custom programming to get it to work. If it were me, I would register a
hidden form field, and call a script function right before the page submits
back to the server. In that script function, copy the InnerHTML property of
the div to the <input type=hidden. . .> and then you can get the data in
server code.
By the way, have you checked out FreeTextBox? It's a .Net WYSIWYG
Html editor. It's used in .Text, nGallery, and I use it in my EZWeb
project: http://workspaces.gotdotnet.com/ezweb.
Jeffrey Palermo
Ok, I worked out an example. copy this source into a blank .aspx file and
run it. It works.\
Initial value.
Initial value.
copy div contents to hidden field.
Jeffrey Palermo
"SamoK" <sn***@wetsoftware.com> wrote in message
news:OP******************@news.siol.net... I've tried document.all["<%=oHidden.ClientID%>"]
but the value is undefined, thus obj.value (obj=document.all["<%....)
threw object Error exception.
As for trace... I could output something like this (despite object Error exception) on post back:
__VIEWSTATE _ctl0:Title _ctl0:Customer _ctl0:Link _ctl0:oHidden
The code was:
foreach(string s in Request.Form.Keys) System.Diagnostics.Trace.WriteLine(s);
But the oHidden.Value in my server code remains "".
Am I annoying? :) This annoys me for the past few days.
Samo K. "Jeffrey Palermo" <je************@yahoo.com> wrote in message news:ez**************@tk2msftngp13.phx.gbl...
For your script, you can do: document.all["<%=oHidden.ClientID%>"].value = oDiv.InnherHTML; Make sure the hidden field is inside your server-side form. Then (with trace turned on) look at your form collection, and you should see that the hidden field posted some data. You're on the right track.
It'll work for you.
In your code-behind, you do have a declared field like protected HtmlInputHidden oHidden; right?
Jeffrey Palermo
"SamoK" <sn***@wetsoftware.com> wrote in message news:Sd******************@news.siol.net... Thanks for your reply... I've created the hidden field like this:
<input type="hidden" id="oHidden" runat="server">
The problem with this is that the server changes the IDs a bit and
when I look at the generated HTML the id is _ctl0_oHidden.
I fill this input with data like this: form1._ctl0_oHidden.value = oDiv.InnerHTML; (if I do form1.oHidden.... i get object Error exception).
And when I do postback, all I get is big nothing (value == "").
I also tried with input type=text, and the script gets the right data
to oHidden (or _ctl0_oHidden).
I'm a bit noob (as you can see) to all this stuff.
- Samo K.
"Jeffrey Palermo" <je************@yahoo.com> wrote in message news:eH**************@TK2MSFTNGP11.phx.gbl... > yes, that's true, but if script modifies the contents of the <div>
on the > client, that content will not get posted back to the server on a postback. > You must look at how ASP.NET works. The server cannot receive any > information unless it receives it in the Querystring or Form collections. A > div is not a normal form field, so it doesn't post anything back, as does > <input type="text" ... .>. You are going to have to do some custom > programming to get it to work. If it were me, I would register a
hidden > form field, and call a script function right before the page submits back to > the server. In that script function, copy the InnerHTML property of the div > to the <input type=hidden. . .> and then you can get the data in
server > code. > > By the way, have you checked out FreeTextBox? It's a .Net WYSIWYG Html > editor. It's used in .Text, nGallery, and I use it in my EZWeb project: > http://workspaces.gotdotnet.com/ezweb. > > Jeffrey Palermo
<%@ Page language="c#" Inherits="System.Web.UI.Page" %>
<html>
<head>
<title>junk</title>
<script language="javascript">
function foo(){
document.all['<%=oHidden.ClientID%>'].value =
document.all['<%=oDiv.ClientID%>'].innerHTML;
}
function bar(textarea){
document.all['<%=oDiv.ClientID%>'].innerHTML = textarea.innerHTML;
}
</script>
</head>
<body>
<form id="Form1" method="post" runat="server">
<input type=hidden id=oHidden runat=server>
<div id="oDiv" runat="server">
Initial value.
</div><br>
<textarea onkeypress="bar(this);">Initial value.</textarea><br>
<button onclick="foo();">copy div contents to hidden field.</button>
<asp:Button ID="btn" Runat="server" Text="Post Back"></asp:Button>
<br>
<asp:Literal ID="lit" Runat="server"></asp:Literal>
</form>
</body>
</html>
<script runat="server">
protected override void OnLoad(EventArgs e)
{
base.OnLoad (e);
if(IsPostBack)
{
lit.Text = oHidden.Value;
}
}
</script>
"SamoK" <sn***@wetsoftware.com> wrote in message
news:OP******************@news.siol.net... I've tried document.all["<%=oHidden.ClientID%>"]
but the value is undefined, thus obj.value (obj=document.all["<%....)
threw object Error exception.
As for trace... I could output something like this (despite object Error exception) on post back:
__VIEWSTATE _ctl0:Title _ctl0:Customer _ctl0:Link _ctl0:oHidden
The code was:
foreach(string s in Request.Form.Keys) System.Diagnostics.Trace.WriteLine(s);
But the oHidden.Value in my server code remains "".
Am I annoying? :) This annoys me for the past few days.
Samo K. "Jeffrey Palermo" <je************@yahoo.com> wrote in message news:ez**************@tk2msftngp13.phx.gbl...
For your script, you can do: document.all["<%=oHidden.ClientID%>"].value = oDiv.InnherHTML; Make sure the hidden field is inside your server-side form. Then (with trace turned on) look at your form collection, and you should see that the hidden field posted some data. You're on the right track.
It'll work for you.
In your code-behind, you do have a declared field like protected HtmlInputHidden oHidden; right?
Jeffrey Palermo
"SamoK" <sn***@wetsoftware.com> wrote in message news:Sd******************@news.siol.net... Thanks for your reply... I've created the hidden field like this:
<input type="hidden" id="oHidden" runat="server">
The problem with this is that the server changes the IDs a bit and
when I look at the generated HTML the id is _ctl0_oHidden.
I fill this input with data like this: form1._ctl0_oHidden.value = oDiv.InnerHTML; (if I do form1.oHidden.... i get object Error exception).
And when I do postback, all I get is big nothing (value == "").
I also tried with input type=text, and the script gets the right data
to oHidden (or _ctl0_oHidden).
I'm a bit noob (as you can see) to all this stuff.
- Samo K.
"Jeffrey Palermo" <je************@yahoo.com> wrote in message news:eH**************@TK2MSFTNGP11.phx.gbl... > yes, that's true, but if script modifies the contents of the <div>
on the > client, that content will not get posted back to the server on a postback. > You must look at how ASP.NET works. The server cannot receive any > information unless it receives it in the Querystring or Form collections. A > div is not a normal form field, so it doesn't post anything back, as does > <input type="text" ... .>. You are going to have to do some custom > programming to get it to work. If it were me, I would register a
hidden > form field, and call a script function right before the page submits back to > the server. In that script function, copy the InnerHTML property of the div > to the <input type=hidden. . .> and then you can get the data in
server > code. > > By the way, have you checked out FreeTextBox? It's a .Net WYSIWYG Html > editor. It's used in .Text, nGallery, and I use it in my EZWeb project: > http://workspaces.gotdotnet.com/ezweb. > > Jeffrey Palermo
Hey, thanks for your time and example (I never doubted to what you say, it
just didn't work for me;)).
I found out what the problem was. It has something to do with fact that I
had all this stuff (Div, Hidden fields,...) in ascx control that was loaded
onto aspx control. And that's the reason why scripts wasn't functioning the
way I/we wanted them :)
I solved the problem now, and thanks again for taking time to clear some
things to me.
Regards,
Samo Kralj
"Jeffrey Palermo" <je************@yahoo.com> wrote in message
news:ea*************@TK2MSFTNGP10.phx.gbl... Ok, I worked out an example. copy this source into a blank .aspx file and run it. It works.\ Initial value.
Initial value. copy div contents to hidden field. Jeffrey Palermo This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: UrgeOverkill |
last post by:
I'm having a problem sending data from a socket server. The server
side reports that it has sent 4845 bytes but the client reports only
1448 bytes received. The kicker is that this ONLY happens...
|
by: Daniel |
last post by:
after opening socket, sending data then closing socket 3000 times i get
"Only one usage of each socket address"
what am i doing wrong? is there some thing else i need to do to free up the
socket...
|
by: Daniel |
last post by:
how to change the value of Request.ServerVariables on the
ser ver? if not possible is there some way to change it by sending back
javascript to the client and having the client automaticaly do...
|
by: David |
last post by:
I'm wondering if python is capable of fairly precise timing and also sending
data out the parallel port.
For example ; making a 7.5 KHz square wave come out of one of the data pins
on the...
|
by: yaron |
last post by:
Hi,
I have a problem when sending data over TCP socket from c# client to java
server.
the connection established ok, but i can't send data from c# client to java
server.
it's work ok with...
| |
by: vladimir.plotnikov |
last post by:
Hello!
I have problem:
I have IPB forum installed. After search in IPB (search takes about 3-4
seconds for post table about 300 000 records) mysql shows "Sending
Data"
status and takes about...
|
by: Charlie |
last post by:
Hi:
I need a way to test my TcpListner, but not sure what applications are
sending data to tcp ports. How about Email or Instant Messenger? If they
are tcp, what ports are they sending data...
|
by: Navin Mishra |
last post by:
Hi,
In load test of our .NET 2.0 socket application on Win2003 server, we are
seeing sometimes
WSEWOULDBLOCK error when sending data to clients. We are using synchronoous
scokets with...
|
by: placid |
last post by:
Hi All,
Just wondering if there is any way of sending a JavaScript array to a
Python cgi script? A quick Google search didn't turn up anything
useful.
Any help appreciated.
Cheers
|
by: Mateo |
last post by:
(As.Net 1.1 framework!)
Hi!
So, I have problem as described in subject.
Here is source code:
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
|
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,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
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 ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |