alert problem in c# asp.net

  • (2 Pages)
  • +
  • 1
  • 2

16 Replies - 4036 Views - Last Post: 28 April 2011 - 05:25 AM Rate Topic: -----

#1 G_rose42  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 51
  • Joined: 15-December 10

alert problem in c# asp.net

Posted 01 April 2011 - 02:02 AM

Hi..
am using alert box in my asp.net login page... after i check username and password if it is wrong i have to show alert... but my problem is when i show alert my background picture disappears till alert closed...
to alert i used
ScriptManager.RegisterStartupScript(this.Page,this.GetType(),"Alert","alert('Enter the valid username & password')",true);

thank u
Is This A Good Question/Topic? 0
  • +

Replies To: alert problem in c# asp.net

#2 marinus  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 135
  • View blog
  • Posts: 575
  • Joined: 14-April 10

Re: alert problem in c# asp.net

Posted 01 April 2011 - 02:27 AM

This is a normal effect for Javascript alert ,
try the window.Open Method to create your own popup ,
or look for jQuery popups.

This post has been edited by marinus: 01 April 2011 - 02:27 AM

Was This Post Helpful? 0
  • +
  • -

#3 G_rose42  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 51
  • Joined: 15-December 10

Re: alert problem in c# asp.net

Posted 01 April 2011 - 02:49 AM

thank u... but i do no jquery... let me try
Was This Post Helpful? 0
  • +
  • -

#4 marinus  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 135
  • View blog
  • Posts: 575
  • Joined: 14-April 10

Re: alert problem in c# asp.net

Posted 01 April 2011 - 02:56 AM

Wait......!!

I got the problem :)

The alert starts before page loads so what i found as the work around is.

modify <body> tag as follows

<body runat="server" id="myBody">


Then in the Code Behind\C# file add this in PageLoad event.

 protected void Page_Load(object sender, EventArgs e)
        {

         myBody.Attributes.Add("onload","alert('hello');");
        }


This waits until the all the html is loaded and only then it will alert you.

I think the script manager puts the script in the <head> tag which means the script will load immediately which is not what you wanted .


I think we are Winning! :bananaman:


Greetings

Marinus

This post has been edited by marinus: 01 April 2011 - 02:59 AM

Was This Post Helpful? 1
  • +
  • -

#5 G_rose42  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 51
  • Joined: 15-December 10

Re: alert problem in c# asp.net

Posted 01 April 2011 - 03:06 AM

Actually my problem is i have one button as login... when i click login after i entered username and password it will check database is name ans password correct id it s wrong then only i need alert....
i used database checking in if it s wrong it comes to else and give alert...
Was This Post Helpful? 0
  • +
  • -

#6 marinus  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 135
  • View blog
  • Posts: 575
  • Joined: 14-April 10

Re: alert problem in c# asp.net

Posted 01 April 2011 - 03:10 AM

Then modify like follow

void btnLogin_Click(object sender , EventArgs e)
 {
   //Database search for user.

   if(UserValid)
     myBody.Attributes.Add("onload","alert('hello');");
   else
     myBody.Attributes.Add("onload","alert('enter password & Username');");

 }


This post has been edited by marinus: 01 April 2011 - 03:14 AM

Was This Post Helpful? 1
  • +
  • -

#7 G_rose42  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 51
  • Joined: 15-December 10

Re: alert problem in c# asp.net

Posted 01 April 2011 - 03:46 AM

wait
Was This Post Helpful? 0
  • +
  • -

#8 G_rose42  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 51
  • Joined: 15-December 10

Re: alert problem in c# asp.net

Posted 01 April 2011 - 03:57 AM

hey man... its working superb... thanks a lot ..
i catch u soon with another prob
Was This Post Helpful? 0
  • +
  • -

#9 marinus  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 135
  • View blog
  • Posts: 575
  • Joined: 14-April 10

Re: alert problem in c# asp.net

Posted 01 April 2011 - 03:59 AM

Don't forget to click the Was This Post Helpful?(+) if i helped you , that would be awesome .

This post has been edited by marinus: 01 April 2011 - 04:04 AM

Was This Post Helpful? 0
  • +
  • -

#10 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6110
  • View blog
  • Posts: 23,670
  • Joined: 23-August 08

Re: alert problem in c# asp.net

Posted 01 April 2011 - 04:53 AM

Moved to ASP.NET
Was This Post Helpful? 0
  • +
  • -

#11 G_rose42  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 51
  • Joined: 15-December 10

Re: alert problem in c# asp.net

Posted 04 April 2011 - 01:27 AM

hi....
can u solve this same alert prob with ajax.. can means help me..
Was This Post Helpful? 0
  • +
  • -

#12 G_rose42  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 51
  • Joined: 15-December 10

Re: alert problem in c# asp.net

Posted 19 April 2011 - 08:56 PM

hi marinus.. suddenly your code myBody.Attributes.Add("onload","alert('hello');");
is not working i do the reason again am hav same prob if alert comes my background pic disappear till alert close.
Was This Post Helpful? 0
  • +
  • -

#13 marinus  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 135
  • View blog
  • Posts: 575
  • Joined: 14-April 10

Re: alert problem in c# asp.net

Posted 27 April 2011 - 03:32 AM

That's weird because onload works after html page has been loaded ,

As you can see here what i mean

http://stackoverflow...after-page-load



have you fixed this ??

This post has been edited by marinus: 27 April 2011 - 03:36 AM

Was This Post Helpful? 0
  • +
  • -

#14 G_rose42  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 51
  • Joined: 15-December 10

Re: alert problem in c# asp.net

Posted 28 April 2011 - 01:30 AM

No not yet finished man
Was This Post Helpful? 0
  • +
  • -

#15 G_rose42  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 51
  • Joined: 15-December 10

Re: alert problem in c# asp.net

Posted 28 April 2011 - 01:35 AM

I couldn't understand that in stackoverflow
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2