Link to home
Start Free TrialLog in
Avatar of ANAT2403
ANAT2403Flag for Israel

asked on

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
   
Avatar of SuperGhosty
SuperGhosty

public void ShowMessage(string keymsg)
    {
      string myScript = @"<script language='javascript'>alert('this is my message)</script>";
        Page.ClientScript.RegisterStartupScript(this.GetType(), "MyScript", myScript, true);
    }
>> 'this is my message << needs to be: 'this is my message'
ASKER CERTIFIED SOLUTION
Avatar of Jojo1771
Jojo1771

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
Avatar of ANAT2403

ASKER

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.
hmmm...I don't see any points here
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
don't you use copy-paste???