Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9312439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T01:37:51+00:00 2026-06-19T01:37:51+00:00

I am relatively new to web development and completely new to ASP.NET Web Forms.

  • 0

I am relatively new to web development and completely new to ASP.NET Web Forms.
I have the following user control :

CSS:

div.textareaDiv {
    -moz-appearance: textfield-multiline;
    -webkit-appearance: textarea;
    border: 1px solid gray;
    font: medium -moz-fixed;
    font: -webkit-small-control;
    height: 200px;
    padding: 2px;
    resize:both;
    width: 400px;
    word-wrap: break-word;
    word-break:normal;
}

Script :

function CatchEnterKey(e) {
        if (e.keyCode == 13) {
         e.stopPropagation();
         return false;
     }
     return true;
 }

Markup :

<div id='HtmlTextField' style="height:200px!important;"   class="textareaDiv"     onkeypress="CatchEnterKey(event);"  contenteditable="true" unselectable="off" runat="server"></div>;

And the following code-behind function gets called, when “submit” button on parent page is
pressed :

public string GetHtml()
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "gethtml", "alert($('.textareaDiv').html());", true);
                return null;
        }

The idea is to return inner html of the div through script execution, but currently I just want to figure out, why I am getting empty alert. Is it that the inner html of the div really gets emptied on postback, and I need to think of a different solution, or am I doing anything wrong?

Thanks in advance

Roman

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T01:37:52+00:00Added an answer on June 19, 2026 at 1:37 am

    See this post on SO. Switch your example to use RegisterStartupScript instead. The issue is that RegisterClientScriptBlock registers before the elements are rendered to screen, so the element isn’t even rendered when you run that code. RegisterStartupScript renders after all of the elements.

    Also, JQuery also supports delaying running script until after everything is loaded. If you wrap your code with:

    $(document).ready(function() { /* alert code here */ });
    

    Or shorthand:

    $(function() { /* alert code here */ });
    

    This delays execution until document ready. That’s another alternative.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am relatively new to ASP.NET programming, and web programming in general. We have
Currently where I work we have the following set-up (for ASP.NET web-development) using Git
I am relatively new to Web Parts and Web Forms (I have only worked
I have a .net development background but relatively new to Java world. We have
I am relatively new at using ASP.NET MVC, however I have got experience with
I am relatively new to web development and web applications. I have heard about
I am relatively new to web development and learning all the time. I have
I'm relatively new to php development but not to web development in general. I
I am completely new to web development, so please forgive me in case this
I am relatively new to web development, and I was hoping I could get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.