Developers might want to display client side message with information from server side to their users when they have completed some execution at server side. People may try in different way for this purpose.
For example:
Response.Write() method with JavaScript code inside the method:
string mes = "Hello Dhaka";
Response.Write("<script language=\"javascript\" type=\"text/javascript\">alert('" + mes + "');</script>");
But these code doesn't work when you use update panel in your page. So better solution is to use ScriptManager.RegisterStartupScript() method. This works whether update panel is used or not. So let's see the code snippet below:
string message = string.IsNullOrEmpty(TextBox1.Text) ? "Please give a text to textbox." : "You have given: " + TextBox1.Text.Trim(); string script = "<script language=\"javascript\" type=\"text/javascript\">alert('" + message + "');</script>"; ScriptManager.RegisterStartupScript(Page, this.GetType(), "AlertMessage", script, false);
With this code snippet you can display a modal message that their data was saved or updated successfully or not.
Gridview control is a customizable and flexible control used to display data in tabular format. It has some nice features. But lacks of some client side features that makes web users happy. We can easily add these features with few lines of code.
For example, a common task is to highlight gridview row on mouse over which is not provided with gridview control. Here we will see how easily we can do the task.
In order to change gridview row color we need to add/remove style attributes to that specific row using JavaScript onmouseover and onmouseout client event. We can do it on RowDataBound or RowCreated gridview event.
Hi, This is Md. Saiful Islam. I am from Dhaka, Bangladesh.I am a passionate .Net developer about 5 years of development experience. Currently, I am working for a Software Development Company called CACTS Limited as a Sr. Software Engineer(Team Lead) for web and desktop applications. I am a 820 point Participant of http://forums.asp.net/.
An Ops Checklist
-
A couple of years back, I spent two months reading through over two
thousand outage incidents from our incident database: what caused it, how
people identi...