inicio mail me! sindicaci;ón

GridView is added delete pushbutton final measure

These two days use GridView, as it happens is encountered should add delete affirm this operation, the search on the net one, this is best, For Gridview ” delete ” the row is added affirm a dialog box 

Mention a kind of method to be called to be a kind of the most concise method among them, as expected pretty good, analyse very well also.

Nevertheless, I encountered the situation that find both funny and annoying however in used process: The problem of quote

<asp:COmmandField EditText=” is revised “

CancelText=” cancels “

DeleteText=’<span Class="handle" Onclick="JavaScript:rEturn Confirm(“Confirm_this “) "> deletes </span>’

 

HeaderText=” operation “

ButtonType=”Link “

ShowEditButton=”true “

ShowDeleteButton=”true” />

Look among them gules part, this part code is incorrect, becauseDouble quote can cause Javascript error, you think,

<span Class="handle" Onclick=JavaScript:rEturn Confirm(Eturn Confirm(Confirm_thisConfirm_thisConfirm_thisConfirm_this> delete </span>

These 4 quote can be used, cannot. Must be here one onefold double quote alternate with, code ability is normal.

But also cannot trade only quote, because

<asp:COmmandField EditText=” revises ” CancelText=” to cancel ” DeleteText=<span Class="handle" Onclick="JavaScript:rEturn Confirm(Confirm_this) "> deletes </span>. . .

Because, Only quote can cut off the code of ASP.NET, so, only double quote cannot be used.

Nevertheless, also method is solved, ifDoraeimoThe plan that mentions in Blog is called the most concise, I think, the method below can be called the most ultimate solution, of course, this is to build inDoraeimothis gets on the foundation.

Solution: What quote is useful also!

<asp:COmmandField

EditText=” is revised “

CancelText=” cancels “

DeleteText=’<span Class="handle" Onclick="JavaScript:rEturn Confirm(Confirm_this) "> deletes </span>’

HeaderText=” operation “

ButtonType=”Link “

ShowEditButton=”true “

ShowDeleteButton=”true” />

Nevertheless, in wanting backstage, to the client end registers Javascript script, in Page_Load incident:

Should you delete String SScript = “var Confirm_this=’ certainly? ‘;”;

ClientScriptManager Csm = Page.ClientScript;

If (! Csm.IsStartupScriptRegistered(”_confirm”) )

{

Csm.RegisterStartupScript(this.GetType() , “_confirm” , SScript, true);

}

The principle is very simple, the effect is very economic.

Bookmark:Digg Del.icio.us Reddit

Leave a Comment