Archive for October, 2012

How to apply css style asp button code behind/server side

{0 Comments}

How to apply css style asp button code behind/server side

When it comes to apply css style from code behind/server side there are some properties which you can use to do so as we do to style many control. You can use following syntax to style your button according to your requirement.     C# |  copy code |? 01 protected void Button1_Click(object sender, EventArgs e)02 {03 Button1.BackColor = System.Drawing.Color.PaleGreen;04 Button1.BorderColor=System.Drawing.Color.PaleTurquoise;;05 Button1.BorderStyle=BorderStyle.Dashed;06 …

Read More…

How to avoid multiple button clicks asp net

{0 Comments}

Most of time when user click multiple time accidently, in some situation like submitting a form you need to restrict button click for some time then use following simple code. protected void server_btn_Click(object sender, EventArgs e) { server_btn.Enabled = false; }  C# |  copy code |? 1 protected void server_btn_Click(object sender, EventArgs e)2 {3 server_btn.Enabled = false;4 5 }

Read More…

How to call JavaScript function button click asp net

{0 Comments}

As per our requirement we have to call a java script function on the button click. For this we use traditional JavaScript calling procedure. This will be called on button click event, so the snippets for the code are as follows.   C# |  copy code |? 1protected void server_btn_Click(object sender, EventArgs e)2 {3 System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "script", "your_javascript_function_name()", true);4 }

Read More…

How to refresh a page on click of a button in asp.net

{0 Comments}

to refresh asp.net web page using asp.net button control you can dynamically add following attribute which will call windows reload function  hence you page will be refreshed or reloaded after button press.  C# |  copy code |? 1Button1.Attributes.Add("onclick", "window.location.reload();");

Read More…

How to dynamically add button in asp.net

{0 Comments}

here is a simple syntax to add button in asp.net dynamically or say from code behind. Using this you can add your custom button to the webpage  C# |  copy code |? 1Button btn = new Button();2 btn.ID = "button1";3 btn.Text = "new button";4 form1.Controls.Add(btn);  

Read More…

How to set enter key on a button in asp.net

{0 Comments}

Here I have created a small syntax to set a enter key on a button in asp.net. There is no such event in asp.net. We can do this with the help of JavaScript. For doing this first take a asp.net button control then to assign a click event to it and all your associated code. …

Read More…

How to disable a button in asp.net

{0 Comments}

How to disable a button in asp.net

If you want to disable button after click on button in asp.net, then following syntax will help you. In this a JavaScript disable function is added dynamically to asp.net button on load. So that now if you click first time it works and after this it will disable. Here we are using add function in …

Read More…

How to add print button in asp.net

{0 Comments}

If you want add a print button in asp.net, and then you can access JavaScript’s print function through asp.net button.  In first way you can set the print function in on click event of button in designer mode, syntax for that is as follows: but I found it work for html submit tag better then …

Read More…

How to apply css to label control from code behind in asp.net

{0 Comments}

Following is the bunch of syntax which will help you to apply css styles from code behind c sharp which is as follows  C# |  copy code |? 1Label1.Text = "write what you want";2Label1.Font.Bold = true;3Label1.Font.Name = "arial";4Label1.Font.Size = FontUnit.Larger;5Label1.ForeColor = System.Drawing.Color.Red;6Label1.BackColor = System.Drawing.Color.PaleGreen;7Label1.BorderStyle = BorderStyle.Dashed;8Label1.BorderColor = System.Drawing.Color.PaleTurquoise;

Read More…