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

Page.ClientScript with master page

In VS2005 ASP.NET 2.0 sqlserver 2000:
I use the following function to show error messages in my site:

public void ShowMessage(string keymsg)
    {
      string myScript = @"alert('this is my message)";
        Page.ClientScript.RegisterStartupScript(this.GetType(), "MyScript", myScript, true);
    }
but when I use it in a slave of a master page, it gives an error.
Do I have to define it in the master page ? and how to call it?
Thankyou
Ant
   
0
ANAT2403
Asked:
ANAT2403
  • 3
  • 2
  • 2
  • +1
1 Solution
 
SuperGhostyCommented:
public void ShowMessage(string keymsg)
    {
      string myScript = @"<script language='javascript'>alert('this is my message)</script>";
        Page.ClientScript.RegisterStartupScript(this.GetType(), "MyScript", myScript, true);
    }
0
 
aki4uCommented:
>> 'this is my message << needs to be: 'this is my message'
0
 
Jojo1771Commented:
aki4u is correct..  

Hey SuperGhosty.

You are correct that you need the script tags, but  the last boolean on startupscript; when set to true will gen that for you.


This should work
string myScript = @"alert('this is my message;);";

I just tested it in a master page and it works great.

If this worked, please give pnts to aki4u as he mentioned it 1st. Im just bored and thought I would comment on the issue.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
SuperGhostyCommented:
thats right, i just quickly glanced at the code and was used to ASP.NET 1.1 - which does not have the extra params so you must include the script tag.
0
 
ANAT2403Author Commented:
Jojo1771 is almost correct
this is the solution:
  string myScript = @"alert('this is a message');";

the second tag ' in    - this is a message I forgot to put here but in my program it existed.
the problem was with the ; sign that I didn't know I have to add
Thankyou all.
0
 
aki4uCommented:
hmmm...I don't see any points here
0
 
ANAT2403Author Commented:
because you didn't mention the sign of semicolon ; which was the only problem here.
The closing tag you mention was something I forgot to write in expert exchange but not in the program
0
 
aki4uCommented:
don't you use copy-paste???
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now