Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to pass ClientID in OnClientClick
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
OS:
Windows XP
Database:
MS SQL Server
Divers
Thread ID:
01301882
Message ID:
01302761
Vues:
25
I think I got it. Thanks a million for sticking with me today and sorry for being so slow.

Here is my current code:
 protected void grdvwUsers_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.DataItem != null)
        {
            LinkButton link = e.Row.FindControl("lnkbtnRemoveRole") as LinkButton;

            if (link != null)
            {
                // link.Attributes["href"] = "#";
                link.Attributes["onclick"] = 
                    "document.getElementById('" + 
                    this.HiddenField1.ClientID + "').value ='" + 
                    e.Row.DataItem.ToString() + 
                    "';return confirm('Do you want to remove " + 
                    e.Row.DataItem.ToString() + " from role " + 
                    this.drpSelRole.SelectedValue + "?' );";
                link.CommandArgument = "RemUser";

            }
        }

    }
    protected void lnkbtnRemoveRole_Click(object sender, EventArgs e)
    {
        //int index = this.grdvwUsers.SelectedIndex;
       

                string username = this.HiddenField1.Value;  
                this.drpSelRole.Visible = false;
                try
                {
                    Roles.RemoveUserFromRole(username, drpSelRole.SelectedItem.Value);
                }
                catch (Exception ex)
                {
                    lblMsg.Text = "An exception of type " + ex.GetType().ToString() +
                             " was encountered removing the user from the role.";
                }


                // Re-bind users in role to GridView.

                PopGrid();
            }
But may be there is a better way?

At least now this part is working and I need to work on the Cancel button, which not yet working. Where should I add onClick for it (in which method) - form's load doesn't seem to work.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform