简体   繁体   English

如何将HTML页面的选定文本发送到同一个ASPX页面,而不是另一个面板?

[英]how to send selected text of an HTML page which is inside an aspx panel to the same aspx page but another panel?

I have an aspx page with 2 panels (C# code-behind), (Panel1 & Panel2). 我有一个带2个面板(位于C#代码后面),(面板1和面板2)的aspx页面。 Inside Panel1 I load an HTML page. 在Panel1内部,我加载一个HTML页面。 Inside Panel2 there is an aspx textbox. 在Panel2内部有一个aspx文本框。 I want to select some text of the HTML page in Panel1 and send it to the textbox of Panel2. 我想在Panel1中选择HTML页面的一些文本,然后将其发送到Panel2的文本框。 Would you please say how to do it? 您能说说怎么做吗?

If you know what part you want to select, assign it an ID and a runat="server" value , then you will be able to access it from the code. 如果您知道要选择的部分,请为其分配一个ID和一个runat =“ server”值 ,然后您就可以从代码中访问它。

For example: 例如:

If you have something like this in your HTML: 如果您的HTML中有类似的内容:

<div id="divForCode" runat="server"></div>

Then you can access the contents of the div in code-behind using 然后,您可以使用以下代码访问div的内容

divForCode.InnerHTML;

and

divForCode.InnerText;

So all you would need to do is send it to the textbox (myTextBox.Text = divForCode.InnerHTML; or myTextBox.Text = divForCode.InnerHtml;) 因此,您所需要做的就是将其发送到文本框(myTextBox.Text = divForCode.InnerHTML;或myTextBox.Text = divForCode.InnerHtml;)

Sorry I had to post this as an answer, I don't have enough reputation to comment. 抱歉,我必须将其发布为答案,我没有足够的声誉来发表评论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM