I'm sure it is simple, but it drives me crazy.
I have a ListBox on my page to show artists who call the method when the index changes, and a button that loads the artist from this list on another page when clicked:
<asp:ListBox ID="lbArtists" runat="server" Rows="1" AutoPostBack="true" OnSelectedIndexChanged="ShowArtistsWorks" />
<asp:Button ID="btnEditArtist" runat="server" Text="Edit the artist" OnClick="LoadArtist" />
In addition, I have a similar list of links, which also has an auto-repeat method:
<asp:ListBox ID="lbLinks" runat="server" Rows="1" AutoPostBack="true" OnSelectedIndexChanged="LoadLink" />
The problem is that when invoked ShowArtistsWorks()by pressing btnEditArtist, the method is also called LoadLink(). Why is this happening? Why is this caused when I did not change the index in the lbLinksListBox? He should not come close to this method.
EDIT: (relevant) Code-Code Methods (
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack){
GetArtists();
GetLinks();
}
}
protected void LoadArtist(object sender, EventArgs e){
if (lbArtists.SelectedValue != "")
Response.Redirect("Artist.aspx?id=" + lbArtists.SelectedValue);
}
protected void LoadLink(object sender, EventArgs e)
{
if (lbLinks.SelectedValue != "")
Response.Redirect("Link.aspx?id=" + lbLinks.SelectedValue);
}
№ 2: , , , , , , , .
: , ( CRice) , , , , . , .