Confirmation Message Box using Javascript in between code from Code behind

Hi all,

Im using C# as my code behind, im having a code in the button click event where im checking whether a file is exists, if it exists then it show the confirmation message box like "file found, want to continue", but its happening if we register the script in the page load  and its not checking the condition. By clciking the button itself its showing the message box.

 

i need that script should get pop up only after the condition get satisfied. Is it possible? Please help me out to solve this problem. Thanks a lot in advance.

The code is given below

private

void Page_Load(object sender, System.EventArgs e)

{

i = "file Exists";

StringBuilder str =

new StringBuilder();

str.Append("<script language=javascript>");

str.Append("function PopWindow()");

str.Append("{");

str.Append("alert('hello world')");

str.Append("}");

str.Append("</script>");

if(!Page.IsClientScriptBlockRegistered("clientscript"))

{

Page.RegisterStartupScript("clientscript",str.ToString());

}

Button1.Attributes.Add("onclick","PopWindow();");

}

private void Button1_Click(object sender, System.EventArgs e)

{

if (i=="file Exists")

{

int x= 0;

int y =0;

x = x+ y;

Button1.Attributes.Add("onclick","PopWindow();");

int a = 2;

int z = 2;

z = z+ a;

Response.Write(z.ToString());

}

}

Regards

Mukilan.

0
psmukilan
7/4/2006 10:56:05 AM
asp.net.web-forms 93655 articles. 6 followers. Follow

0 Replies
1405 Views

Similar Articles

[PageSpeed] 52
Get it on Google Play
Get it on Apple App Store

Reply:

Similar Artilces:

How to code confirm message box after code-behind logic
Hello, all  In a GridView, when the user, after making changes in a row, clicks the Update button, I need to query a database table to determine if I need to display a message box. Basically, I need to inform the user that they are about to change other records as a result of the change they want to make in the currently edited row. And give the user the opportunity to cancel the update. A simple client side return/confirm button won't work, as depending on the particular changes the user makes in the record, the change may or may not cause an update ...

Web Forms Designer error
Hi, The web forms designer keeps adding things in a generated InitializeComponent() method. I believe these things shouldn't be there because I've made a new webform with the same code that doesn't add the same stuff. Is there anyway I can see the Web Designer code? Thanks. Just expand out the hidden #region. It is labeled Web Form Designer CodeStarting with ASP.NET 2.0? Look at:Programming Microsoft Web Forms My Blog...

How to call code behind code using javascript ?
Hi I have written code behind for logout button in one page. like That  protected void ImageButton1_Click(object sender, ImageClickEventArgs e)    {        //Code For Logout of User         clsAdminUsers obAdmin = new clsAdminUsers(Request.PhysicalApplicationPath);        obAdmin._UserId = lblID.InnerText;        Application.Lock();        bool blnResult = obAdmin.LogoutUser();   &n...

javascript code using c# code behind
I have a javascript function on html page between , tag. But I want to write that script function on code behind language using C#. In other words I want to move that javascript function on html page to c# code behind language. Can anybody help me please?  You can make use of RegisterStartupScript like  Dim current As ScriptManager = ScriptManager.GetCurrent(Me.Page) If current IsNot Nothing AndAlso current.IsInAsyncPostBack Then ScriptManager.RegisterStartupScript(Me, Me.GetType(), "__AddJS", ";function test() { alert('Test'); }&...

Use datastore in Web form code-behind
I am developing a new web application. I have some reports in old legacy system that are written in PB but have to migrate to web. So I migrate the old dw by Datawindow Designer first. And I decide to instance a datastore in web form code-behind, set its datawindow object and retrieve, then save the output as pdf or excel and redirect the saved file back to the browser. The following is the piece of C# codes: Sybase.DataWindow.DataStore ds = new Sybase.DataWindow.DataStore(); this.oleDbConnection1.Open(); Sybase.DataWindow.AdoTransaction tran = new Sybase.DataWindow.AdoTransa...

how to change these windows form code to web form code?
hi, i'm a beginner of c#,i want to know how to change these windows form code to web form code //////////// private void buttonSign_Click( object sender, System.EventArgs e) { //get original message as byte array byte[] messagebytes = Encoding.UTF8.GetBytes( textOriginalMessage.Text); //create digest of original message using SHA1 SHA1 sha1 = new SHA1CryptoServiceProvider(); byte[] hashbytes = sha1.ComputeHash(messagebytes); //display hash bytes in hex format StringBuilder sb = new StringBuilder(); for (...

how can i convert code behind web forms pages to inline code pages
hi all of you, I have a problem, a have registered a free asp.net space at Brinkster , so i can just upload my files there one by one, but can not install my web application directly, and i have to upload my projects there, so one way is o convert all my VS.NET web application which is code behind, convert that into inline code, so how can i do that Thanks in advanceWarm Regards,Prajesh Kumar JhaE-MAIL : prajesh.jha@rediffmail.com Convert from Code-Behind to Code-Inline: http://www.codinghorror.com/blog/archives/000174.html Darrell Norton, MVPDarrell Norton's BlogPlease m...

Using App_Code shared code in page code-behind AND code-front
Hi all, I've only just come across what seems to be the 'correct' way of making use of shared code in my .Net sites: I code some classes in a .cs (in my case - i'm using c#) file. I then put them inside namespaces. To make use of the classes in the code-behind of my web pages, I simply add a "using MyNamespace;" line at the top, and then I can make use of a class' contents like so: "MyClass1.MyString1(SomeVariablesToSend)". Now that works fine when working in the codebehind, but what happens when I want to call the class/string from my code-fron...

referencing textboxes on web forms using code behind
 Hello: On my web form I have several text boxes named from textbox1 to textbox30. How do I "reference" these text boxes in code behind "vb.net"? Say i wish to write a for loop. for i = 1 to 30 textbox[i].text.length>0 stmt... next i How do I code this part? You can get idea from following link http://forums.asp.net/p/1148526/1866897.aspx-SuganRemember to click “Mark as Answer” on the post If you get answer from this post(s) ! Try the FindControl method.For i = 1 To 30 Dim txt As...

validate web form entries via textbox again in the C# (code-behind) code again
I have requiredfieldvalidators, comparevalidators and a regualarexpressionvalidator for the email on my login form for the textboxes. My question is do I have to check in the C# to make sure the textboxes have values and if so what does a experienced programmer think of my code. What would you change??? Are the if statements the way to go??? Thanks for making me a better coder................newbieprotected void LoginButton_Click(object sender, EventArgs e){string emailAddress = String.Empty;string password = String.Empty;if (!String.IsNullOrEmpty(TextBoxEmailAddress.Text)){emailAddress = Te...

Call javascript function from C# code behind using html source code output
I have three tabs on a Main.aspx page(tabs 1, 2, and 3) created using javascript.  When the user leaves the main page and returns to it (if postback) I need the tab selection to remain in session.  In other words, if the user picks tab "2" then leaves that page (but doesn't close the browser) then returns I want that same tab "2" to be active for them.  That way they don't have to reselect the last tab they were on.  How do I call the function from my code behind page using C# ?  here's some of my javascript code I need help with...

what about the code-behind (code behind)
One MAJOR difference between AJAX.NET and Atlas.NET seems to be that AJAX.NET is able to expose methods in your codebehind to the client. Why doesn't Atlas do this? Or am I mistaken? With AJAX.NET it's just a simple line or two:  Ajax.Utility.RegisterTypeForAjax(GetType(myClass)) <Ajax.AjaxMethod()>Public Function myFunction PLEASE tell me Atlas has something comparable to this. I don't have the time to rewrite all my code-behind methods in javascript or atlas script. All you need to do in Atlas to expose a method on your page (or its code behind class) is to put a [WebMet...

"i want used confirm in javascript in code behind"
  Hai.... "i want used confirm in javascript in code behind" i am used confirm button ,,,in code behind.   if the confirm button worked the function is return the true... else the function return the false.. i want to get true and false value for my further proces.. this my code.. Dim popupScript6 As String = "<script language='javascript'>var agree= confirm('Are you sure to cancel the ticket?');if(agree){ return true};else {return false;}</script>"        'Page.RegisterStart...

Code Behind or not Code Behind
Ok i am confuse now.... A lot of books are showing pages without code behind (the code is integrated in the .aspx) Is it better to use the code behind or not. Is there any difference between using VB.NET or C#.NET except for the code synthax. Thank you and come again. A lot of samples show inline code just for simplicity.. i personally use code-behind because I like to seperate my code from presentation. As for VB.NET or C#, its your preference.. there is no difference really when its all said and done. From a purely mathematical sense, having everything in a single file would s...

Web resources about - Confirmation Message Box using Javascript in between code from Code behind - asp.net.web-forms

Confirmation - Wikipedia, the free encyclopedia
A bishop administering Confirmation. Rogier van der Weyden , The Seven Sacraments , 15th century. normally carried out through anointing , the ...

Confirmation - Wikipedia, the free encyclopedia
A bishop administering Confirmation. Rogier van der Weyden , The Seven Sacraments , 15th century. normally carried out through anointing , the ...

Facebook Reportedly Acquires Gowalla, No Confirmation From Either Company
... “most” of its employees and founder Josh Williams over to Palo Alto headquarters to work on Timeline, according to CNN. We could not get confirmation ...

Twitter reactions to the #Fed confirmation
... over Twitter — the last time that a new chairperson was appointed, Twitter wasn’t around. Within half an hour of the milestone confirmation, ...

Senate Confirmation Hearing (200910150008HQ) - Flickr - Photo Sharing!
U.S. Sen. Jay Rockefeller, D-W.Va., Chairman of the of the Senate Committee on Commerce, Science and Transportation, makes a point during the ...

John Kerry Confirmation Hearing: Questioned About Vietnam vs. Current U.S. Policy - YouTube
Secretary of State nominee, a vet who later protested Vietnam, faces questions from Sen. Rand Paul.

Republicans force delay on Hagel confirmation
... answers from US President Barack Obama's pick to head the Pentagon have forced Senate leaders to delay a vote, throwing Chuck Hagel's confirmation ...

Is this confirmation Prince George and Princess Charlotte's nanny is Mary Poppins?
The christening of Princess Charlotte was touted as &quot;modern&quot;. No one told the nanny.

Jurgen Klopp Liverpool, Jurgen Klopp news, Jurgen Klopp Liverpool confirmation
JURGEN Klopp is officially the new Liverpool manager.

Is this confirmation Prince George and Princess Charlotte's nanny is Mary ...
Sydney Morning Herald Is this confirmation Prince George and Princess Charlotte's nanny is Mary ... Sydney Morning Herald There were many ...

Resources last updated: 11/30/2015 2:28:37 AM