jonatec
asked on
Capturing CommandField button events.
Using ASP 2.0 and the CommandField with a bound DetailsView control. I have three buttons set up. I also have a another button control on the form called "browse" that needs to be disabled if the user clicks on the Edit button, ie..
EDIT DELETE NEW
BROWSE
How do I capture an event from the EDIT button and then disable the BROWSE button ?
Thanks..
EDIT DELETE NEW
BROWSE
How do I capture an event from the EDIT button and then disable the BROWSE button ?
Thanks..
ASKER
Where is the click event for the EDIT button to be found for me to write the C# ?
How do I identify that the EDIT button was clicked ?
How do I identify that the EDIT button was clicked ?
ASKER
This is a section of code where I am using a commandField within a DetailsView. I want to disable the "fileUpload" control button when the "EDIT button is clicked:
<asp:DetailsView id="dvImages"
DataSourceID="objectDataSo urceDetail "
CssClass="dvImages"
runat="server"
AutoGenerateRows="false"
DataKeyNames="iRefNo"
OnItemCommand="detailsView _ItemComma nd"
OnItemInserted="detailsVie w_ItemInse rted"
OnItemUpdated="detailsView _ItemUpdat ed"
OnItemDeleted="detailsView _ItemDelet ed"
OnModeChanging="detailsVie w_ModeChan ging"
GridLines="None" >
<Fields>
<asp:TemplateField>
<ItemTemplate>
<input id="fileUpload"
type="file"
runat="server"
onchange="SetImageURL();"
style="width:480px; font-weight:bold;"/>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField CausesValidation="true"
ButtonType="Button"
ShowEditButton="True"
ShowInsertButton="True"
ShowDeleteButton="True" >
</asp:CommandField>
</Fields>
</asp:DetailsView>
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ------
This is the event that gets called when the EDIT button gets clicked, but I cannot locate the fileUpload control:
public void detailsView_ModeChanging(o bject sender, DetailsViewModeEventArgs e)
{
switch(e.NewMode)
{
case DetailsViewMode.Edit:
{
FileUpload b = dvImages.FindControl("file Upload") as FileUpload;
if (b != null)
{
txtBox.Text = "detailsView_ModeChanging Found.";
}
}
break;
}
}
<asp:DetailsView id="dvImages"
DataSourceID="objectDataSo
CssClass="dvImages"
runat="server"
AutoGenerateRows="false"
DataKeyNames="iRefNo"
OnItemCommand="detailsView
OnItemInserted="detailsVie
OnItemUpdated="detailsView
OnItemDeleted="detailsView
OnModeChanging="detailsVie
GridLines="None" >
<Fields>
<asp:TemplateField>
<ItemTemplate>
<input id="fileUpload"
type="file"
runat="server"
onchange="SetImageURL();"
style="width:480px; font-weight:bold;"/>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField CausesValidation="true"
ButtonType="Button"
ShowEditButton="True"
ShowInsertButton="True"
ShowDeleteButton="True" >
</asp:CommandField>
</Fields>
</asp:DetailsView>
--------------------------
This is the event that gets called when the EDIT button gets clicked, but I cannot locate the fileUpload control:
public void detailsView_ModeChanging(o
{
switch(e.NewMode)
{
case DetailsViewMode.Edit:
{
FileUpload b = dvImages.FindControl("file
if (b != null)
{
txtBox.Text = "detailsView_ModeChanging Found.";
}
}
break;
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
or you can use javascript to disable the browse when the edit is pressed.
if you having problems just post the aspx code and I can set the code for you
Regards