简体   繁体   中英

How to get Span value on back end C#

I created a client portal in asp.net, in which client give me feedback for that a ready paragraph is given and empty space is given for fill up using span asp.net code :

<p style="font-size: larger; color:white; line-height:15pt; font-family:Arial;">
Hi my name is
    <strong>
        <span contenteditable="true" runat="server" id="Sname" class="text" data-placeholder="T.B. Giri" data-focused-advice="_____">
        </span>
    </strong>
</p>

i want this span tag value which may change by client side on button click... thank you

Since you have made it runat=server you can access it on serverside. The span is a HtmlGenericControl at serverside:

string value = Sname.InnerText; 

I would use a Label instead which is rendered as span .

However, in this case i'm fairly sure that you don't get the value that was changed at clientside since it is re-created from ViewState at serverside. If that's true you need to use a different approach like using a HiddenField and set it's value on clientside.

使用隐藏字段保存实际值并从隐藏字段中获取值,使用跨度仅显示

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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