Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

ImageButton in DataGrid wont submit when deployed to live

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Frawls - 06 Mar 2008 22:33 GMT
I have a datagrid which contains an ImageButton.

This datagrid is in a control which is in an aspx page. the aspx page
contains the form:<form id="frmItemDetail" runat="server">

On my local machine the ImageButton submits my page fine. Everything
works fine locally. But when i deploy my site to the live server this
ImageButton will not even submit the page. thats right it doesnt EVEN
SUBMIT the page let alone submit it and then do nothing.

1 I have my databinding put inside if(!Page.IsPostBack) so that my
itemcommand does not get eaten when i click the imagebutton.

2 I have put the necessary code within private void
InitializeComponent()

3 I have created the necessary code for the item command private void
dgItemDetail_ItemCommand(object source, DataGridCommandEventArgs e)

4 i have added the CommandName atttribte to my ImageButton

I am completely stumped as to why this works fine on my local copy but
not on the live server.

I am hosting my site with a commercial hoster so i can attach a
debugger to the live process.

Here are some relevant bits of my code which may help. Any help would
be appreciated?????

--------------------------------------------------------------------------------------------------------------------------------------------------------------------
<asp:DataGrid ID="dgItemDetail"
    Runat="server"
    BorderWidth="0"
    PagerStyle-CssClass="Paging"
    AllowPaging="false"
    AllowSorting="true"
    AutoGenerateColumns="false"
    PageSize="8">
    <Columns>
    <asp:TemplateColumn>
    <ItemTemplate>

    <asp:Label ID="lblLongDescription" Text='<%#
Convert.ToString(DataBinder.Eval(Container.DataItem,"ItemDescription"))
%>' Runat=server >

                                        <asp:ImageButton ID="bttnAddToCart" ImageUrl="../Images/
buttonAddLarge.gif" CommandName="cmdAddToCart" Visible="True"
Runat="server"></asp:ImageButton>

    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
</asp:DataGrid>

------------------------------------------------------------------------------------------------------------------------------------------------------------------

override protected void OnInit(EventArgs e)
{

 InitializeComponent();
 base.OnInit(e);
}

private void InitializeComponent()
{
 this.dgItemDetail.ItemDataBound +=new
DataGridItemEventHandler(dgItemDetail_ItemDataBound);
 this.dgItemDetail.ItemCommand +=new
DataGridCommandEventHandler(dgItemDetail_ItemCommand);
            this.Load += new System.EventHandler(this.Page_Load);
}

------------------------------------------------------------------------------------------------------------------------------------------------------------------

private void dgItemDetail_ItemCommand(object source,
DataGridCommandEventArgs e)
{
 if(e.CommandName.ToString()  != "Page") // paging command
    {
       //buttons
       bttnAddToCart =
(ImageButton)e.Item.FindControl("bttnAddToCart");

       if (((ImageButton)e.CommandSource).CommandName ==
"cmdAddToCart")
          {
    //add the item to the cart and redirect to the cart page
    oCart.AddItemToCart(ItemID, dblChargeForMiniBasket,"0");

    Page.Response.Redirect("SiteCart.aspx");
          }
      }
}

---------------------------------------------------------------------------------------------------------------------------------------------------------------------
cs_in_va - 06 Mar 2008 23:04 GMT
On your ImageURL try using "~/images/filename" instead of ../images

I had same problem and that fixed it for me.
Frawls - 06 Mar 2008 23:17 GMT
Thanks for the reply  cs_in_va. Itried using ~ but unfortunately it
didnt work....

Any other ideas? Why is this happening?

> On your ImageURL try using "~/images/filename" instead of ../images
>
> I had same problem and that fixed it for me.
Frawls - 07 Mar 2008 10:00 GMT
Can anyone help please?? Still no ideas......

> Thanks for the reply  cs_in_va. Itried using ~ but unfortunately it
> didnt work....
[quoted text clipped - 6 lines]
>
> - Show quoted text -

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.