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 8876423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:12:37+00:00 2026-06-14T19:12:37+00:00

I have a Image Button declared as, <div> <asp:ImageButton ID=btnDoWork runat=server ImageUrl=/_LAYOUTS/1033/IMAGES/row.png ValidationGroup=Page />

  • 0

I have a Image Button declared as,

<div>
    <asp:ImageButton ID="btnDoWork" runat="server" ImageUrl="/_LAYOUTS/1033/IMAGES/row.png" ValidationGroup="Page" />
</div>
<div>
    <asp:RequiredFieldValidator runat="server" ID="reqName" ControlToValidate="txtEmail" ValidationGroup="Page" ErrorMessage="enter a email" />
    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ValidationExpression="^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$" ControlToValidate="txtEmail" ValidationGroup="Page" ErrorMessage="enter a email" />
</div>

within a update panel,

now in code behind I am doing something like this,

btnDoWork = (ImageButton)this.control.FindControl("btnDoWork"); //this code is in childcontrols method
btnDoWork.Click += new ImageClickEventHandler(btnDoWork_Click);

then

protected void btnDoWork_Click(object sender, ImageClickEventArgs e)
        {

//Process a bit of code and at end,

this.Page.Unload += new EventHandler(Page_Unload_MessageBox);

and then in button click event,

public static void Page_Unload_Page_Unload_MessageBox(object sender, EventArgs e)
        {
            System.Globalization.CultureInfo _culture = Thread.CurrentThread.CurrentUICulture;
            StringBuilder sb = new StringBuilder();
            sb.Append("<script language=\"javascript\">");
            sb.Append("$('body').append(\"<div id='M'><span id='text'>" +
               SPUtility.GetLocalizedString("$Resources:abc", "def", (uint)_culture.LCID) +
               "</span><br/><div id='BB' onclick='return BB();'><a href='' onclick='return BB();'>" +
               SPUtility.GetLocalizedString("$Resources:OK", "def", (uint)_culture.LCID) +
               "</a></div></div>\");");
            sb.Append("function BB() { $('#M').remove(); $('#E').remove(); return false; }");
            sb.Append("function dM(){   var browser = navigator.appName; if (browser == 'Netscape') { $('#M').css({ 'top': '5%' }, 500);    } }");
            sb.Append("</script>");

            // Write the JavaScript to the end of the response stream.
            HttpContext.Current.Response.Write(sb.ToString());

Now if I put email address I get error while when it tries to Response.Write I think, I wonder what alternative is there, e.g. can I use triggers in update panel or any other event or something..

here’s the error I am getting now,

on Chrome and IE

Note: I changed all variable names so don’t get confused if something doesn’t match

  • 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-14T19:12:38+00:00Added an answer on June 14, 2026 at 7:12 pm

    The message is very clear, you can not add this command HttpContext.Current.Response.Write on update panel, and that because can not know how to handle it, because the update panel is return a struct that is used by the javascript to redraw some part of the page.

    The solution is to add a literal control inside the UpdatePanel, in the place you wish to add the extra html code, and write that control the render as:

    txtLiteralID.Text = sb.ToString();
    

    How ever, here you have a diferent situation than the normal, you won to render and run a script.

    The main problem is how to trigger the script to run. The only way is to use the UpdatePanel handler that is this standard code:

    <script type="text/javascript"> 
       // if you use jQuery, you can load them when dom is read.
       $(document).ready(function () {
           var prm = Sys.WebForms.PageRequestManager.getInstance();    
           prm.add_initializeRequest(InitializeRequest);
           prm.add_endRequest(EndRequest);
    
        });        
    
        function InitializeRequest(sender, args) {
        }
    
        function EndRequest(sender, args) {
           // after update occur on UpdatePanel run the code.
           UnloadMsgBox();
        }
    </script>
    

    Now on the EndRequest you need to call your script, where it may all read exist in your code as:

    function UnloadMsgBox()
    {
        // render your code of the javascript.
        $('body').append(\"<div id='M'><span id='text'></span><br/><div id='BB' onclick='return BB();'><a href='' onclick='return BB();'></a></div></div>\");
    
        function BB() { $('#M').remove(); $('#E').remove(); return false; }"
        function dM(){   var browser = navigator.appName; if (browser == 'Netscape') { $('#M').css({ 'top': '5%' }, 500);    } }"
    }
    

    and not need to render it on UpdatePanel.

    To summarize:

    • On the update panel you can not use the Response.Write to render something but a literal control, that renders inside him.
    • On the update panel you can not render javascript code and expect to run, to run a javascript code you need to use the EndRequest handler that comes with the UpdatePanel.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Image button defined as follow, <div> <asp:ImageButton ID=btn1 runat=server ImageUrl=/_LAYOUTS/1033/IMAGES/row.png />
In .ascx page i have image button as follows: <asp:Image ID=imgPhotos runat=server Width=102 Height=82/>
I have setup background image for a button as below. // declarations globally declared...
I have one image submit button like this <input id=enter name=enter type=image value=Login src=images/btn_login.jpg/>
I have a image button placed for each row of a datagrid? using item
I have a image button thats acts as a form submit button: <a href=#
I have a problem that when I click on the image button instead of
I have given bg image for radio button. It is working in chrome but
I have placed an Image as a button in my App and I want
I have put image as background of button. but I don't know at what

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.