Click here to Skip to main content
11,437,713 members (50,696 online)
Rate this: bad
good
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 22: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 at 18-Nov-11 22:16pm
   
thanks
Rubaba at 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 at 3-Dec-11 11:45am
   
nice links.5*
Monjurul Habib at 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)



Advertise | Privacy | Mobile
Web04 | 2.8.150506.1 | Last Updated 18 Nov 2011
Copyright © CodeProject, 1999-2015
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