我使用的是Asp .Net Web Forms。我有2个dropDown列表和1个输入字段。我希望当我更改dropDown列表中的项目或字段值来调用某个事件但它调用所有事件时。
例如,如果我更改大小,则调用Size_SelectedIndexChanged,然后调用Color_SelectedIndexChanged,然后调用txtKolicina_TextChanged 如果我更改颜色,则调用Color_SelectedIndexChanged,而不是Size_SelectedIndexChanged,然后调用txtKolicina_TextChanged。
任何帮助?
import pygame
from itertools import product, chain
pygame.init()
screen = pygame.display.set_mode((300, 300))
clock = pygame.time.Clock()
board = {(0,0),(1,0),(1,1),(0,1),(2,3),(2,2),(3,3),(3,2)}
pygame.time.set_timer(pygame.USEREVENT, 1500)
CELLSIZE = 32
H_CELLSIZE = CELLSIZE / 2
def neighbors(point):
x,y = point
for dx, dy in product((-1,0,1), repeat=2):
if dx != 0 or dy != 0:
if x + dx >= 0 and y + dy >= 0:
yield x + dx, y + dy
def step(board):
new_board = set()
with_neighbors = board | set(chain(*map(neighbors, board)))
for point in with_neighbors:
count = sum((neigh in board) for neigh in neighbors(point))
if count == 3 or (count == 2 and point in board):
new_board.add(point)
return new_board
def scr_to_board(pos):
x, y = pos
return (x / CELLSIZE , y / CELLSIZE)
def board_to_scr(pos):
x, y = pos
return (x * CELLSIZE + H_CELLSIZE, y * CELLSIZE + H_CELLSIZE)
while True:
if pygame.event.get(pygame.QUIT):
break
for e in pygame.event.get():
if e.type == pygame.MOUSEBUTTONDOWN:
board ^= {scr_to_board(pygame.mouse.get_pos())}
if e.type == pygame.USEREVENT:
board = step(board)
screen.fill(pygame.color.Color('white'))
for cell in board:
pygame.draw.circle(screen, pygame.color.Color('black'), board_to_scr(cell), H_CELLSIZE, 0)
pygame.display.flip()
clock.tick(60)
这是backEnd
<asp:DropDownList ID="Colors" runat="server" AutoPostBack="true" CssClass="form-control detal-page-input" Style="height: 30px;" OnSelectedIndexChanged="Colors_SelectedIndexChanged" AppendDataBoundItems="True" DataSourceID="LinqDataSource3" DataTextField="color" DataValueField="color" >
<asp:ListItem Text="" Value=""></asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="Size" runat="server" OnSelectedIndexChanged="Size_SelectedIndexChanged" AppendDataBoundItems="true" AutoPostBack="true" CssClass="form-control detal-page-input" Style="height: 30px;" DataSourceID="LinqDataSource2" DataTextField="size" DataValueField="size" EnableViewState="true">
<asp:ListItem Text="" Value=""></asp:ListItem>
</asp:DropDownList>
<asp:TextBox Name="txtKolicina" ID="txtKolicina" runat="server" CssClass="form-control form-numberone detal-page-input" OnTextChanged="txtKolicina_TextChanged" ></asp:TextBox>
更新
protected void Size_SelectedIndexChanged(object sender, EventArgs e)
{
//do something
}
protected void Colors_SelectedIndexChanged(object sender, EventArgs e)
{
//do something
}
protected void txtKolicina_TextChanged(object sender, EventArgs e)
{
//do something
}
答案 0 :(得分:0)
看起来您使用View State并在Postback上的代码中重新填充DropDownLists。你能展示OnInit和OnLoad吗?
或者只是尝试这段代码:
WHERE (articles.statut = ?
OR statut IS NULL)";
$sql .= " AND categories.nom LIKE ? ";
答案 1 :(得分:0)
好的,我发现了什么问题。 改变
的EnableViewState = “假”
到
EnableViewState="true"