Click here to Skip to main content
12,508,630 members (54,306 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET
Hi

Below is my code to display a popup

Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "script", "alert('Record Successfuly saved');", true);

i am getting a error "
Error   12  An object reference is required for the non-static field, method, or property 'System.Web.UI.Page.ClientScript.get' 


could you please guide what to do?


Thanks
Posted 16-Nov-11 21:53pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Hi,

Try this instead of above...
Page.ClientScript.RegisterStartupScript(GetType(), "script","alert('Record Successfuly saved');", true);

Pleased don't forget to vote if help...

Regards,
  Permalink  
Comments
Arokia Mary 18-Nov-11 22:16pm
   
thanks
Rubaba 3-Dec-11 11:45am
   
good call.5*
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
Comments
Rubaba 3-Dec-11 11:45am
   
nice links.5*
Monjurul Habib 3-Dec-11 13:03pm
   
thank you Rubaba.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

replace this with

Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "script", "alert('Record Successfuly saved');", true);

this
Page.ClientScript.RegisterStartupScript(this.GetType(), "aa", "<script language="'javascript'">alert('Record Successfuly saved');</script>");
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 5

instead of typeof(page) use Page.GetType() and try
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

Page.ClientScript.RegisterStartupScript
(this.Gettype(),"Hello","alert('Hello Guys');",true);

try above code u won't get this error
  Permalink  
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160927.1 | Last Updated 18 Nov 2011
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100