i need help in 2 things:
first i have several imagebutton so dynamically i change their ID but when i click in a button the ID reset to default = the ID before run time,so because the page reset because the page returned to the server ,but is their any method to remain this ID? because in the form load i write: if not page.postback <code> end if
so in the form load i change the iD,so any idea how to remain them?
i need to know the ID of the imagebutton who caused the postback but with no result i have an empty string.
so really i need your advices.
Can you show the code then i might able to usderstand the problem better and mention in it what you want to do
i want this:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:ImageButton ID="ImageButton1" runat="server" /> <asp:Button ID="Button1" runat="server" Text="Button" /></div> </form> </body> </html>
the code behind :
Partial Class _Default Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then ImageButton1.ID = "name" End If End Sub End Class
so run the page and view the source you see that the id of the imagebutton is "name" so click the button again the id of the imagebutton reset to "imagebutton1" and i wont this.
so it's a part of a big project so i want the ID to remain even the page is postback to the server.