• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 658
  • Last Modified:

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

0
sbornstein2
Asked:
sbornstein2
  • 6
  • 5
1 Solution
 
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
 
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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
 
EspavoCommented:
You may be able to write the values to a Session...
And then set the value of the label to the Session...
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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now