ASP.Net/C# - Confirm Box question

Hello all,

I am trying to get this to work.  If I drop a literal on an ASPX page in my project and then on the click of a button I run some code then I write to the literal javscript alert text, it works perfect.  However, on this one page I have a control and on that ASCX control I have the same literal.  Also on this control is an AJA update panel but the literal is outside the update panel itself.  When I write to the literal in my code behind the alert never comes up and it is not showing in the source.  Any idea what may be the issue?
private void SayScriptAlert(string message)
        {
            // Format string properly
            message = message.Replace("'", "\'");
            message = message.Replace(Convert.ToChar(10), '\n');
            message = message.Replace(Convert.ToString(13), "");
 
            // Display as javascript confirm box
            ltlAlert.Text = "<script>alert('" + message + "');</script>";
        }

Open in new window

sbornstein2Asked:
Who is Participating?
 
EspavoConnect With a Mentor Commented:
You may be able to write the values to a Session...
And then set the value of the label to the Session...
0
 
EspavoCommented:
Is the button that's triggering this event in the update panel?
Only items in the update panel will be affected when you click the button if this is the case...
 
0
 
sbornstein2Author Commented:
yes the button is in the update panel, the literal is not but I tried placing that in and it still did not update.
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
sbornstein2Author Commented:
I placed the literal in the update panel and then instead of writing the <script> tags into it I just changed the text.  That seemed to work fine and changed on the button click.  When I write the script tags in it the literal shows nothing but no message box comes up.
0
 
EspavoCommented:
Are the script tags dynamically generated based on the Button click? (Do they have to be there like that?)
0
 
sbornstein2Author Commented:
yes I beleive so.  I think this has to do with the linkbutton being within the update panel.  The only issue is that the link button is in a repeater header field that is within the overall update panel.  I am trying to figure out if I can somehow exclude that linkbutton from the update panel asynch.
0
 
EspavoCommented:
What does the message say, and is there ALWAYS a message when the button is clicked?
Why not use the ConfirmButtonExtender?
0
 
sbornstein2Author Commented:
okay I actually have a better idea but still think I have issues.  I placed a label in the repeater so now on the button click to do the processing code I then can write to the label in the repeater.  Now the issue is though there is a timer on the page and the update panel and then a trigger for asynch on the timer.  So what happens is every second the label goes back to blank and it get's rid of the result I want to show.  I don't want to place the label outside the repeater in the panel either because the ajax will freeze the page where it is and then they would have to scroll if that makes sense to the top for example.  Is there a way I can somehow hold those values in the repeater labels?
0
 
sbornstein2Author Commented:
ya but its a repeater so that could get ugly because I would have to know the ID etc and store a list almost.
0
 
EspavoCommented:
Sorry... I'm not grasping exactly what it is that you are doing / trying to achieve, and as such I'm at a loss...
0
 
sbornstein2Author Commented:
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.