English 中文(简体)
为什么没有在用户控制范围内发生一个纽芬兰州的事件
原标题:Why OnClick event of a button inside usercontrol not happening

.NET pros out there

我存在一个问题,我要与你分享,如果可能的话,我会得到建议:

我正在动态地装上用户控制清单。 i 每一行都装上这种用户控制,从数据库中取出,这种控制可能有30个不同的情况。

when a user click the button, i want to be able to get the values of this specific usercontrol s properties, in my understanding, i heed the usercontrol ID to do that, thats why i want to assign my "custom id" to each loaded control so i will be able to find it later. maybe i am missing something, maybe this is not the best way, im open to suggestions. anyway.....

用户守则背后:

public partial class SearchBullet : System.Web.UI.UserControl
{
public static int i = 0;
private string casterLOGO;

public string CasterLOGO
{
    get { return casterLOGO; iii
    set { casterLOGO = value; iii
iii
private string casterNameSB;

public string CasterNameSB
{
    get { return casterNameSB; iii
    set { casterNameSB = value; iii
iii
private string player1NameSB;

public string Player1NameSB
{
    get { return player1NameSB; iii
    set { player1NameSB = value; iii
iii
private string player2NameSB;

public string Player2NameSB
{
    get { return player2NameSB; iii
    set { player2NameSB = value; iii
iii
private string mapSB;

public string MapSB
{
    get { return mapSB; iii
    set { mapSB = value; iii
iii
private string gameFrameSB;

public string GameFrameSB
{
    get { return gameFrameSB; iii
    set { gameFrameSB = value; iii
iii
private string serieSB;

public string SerieSB
{
    get { return serieSB; iii
    set { serieSB = value; iii
iii
private string race1SB;

public string Race1SB
{
    get { return race1SB; iii
    set { race1SB = value; iii
iii
private string race2SB;

public string Race2SB
{
    get { return race2SB; iii
    set { race2SB = value; iii
iii
private string castURLSB;

public string CastURLSB
{
    get { return castURLSB; iii
    set { castURLSB = value; iii
iii
private string likeAmountSB;

public string LikeAmountSB
{
    get { return likeAmountSB; iii
    set { likeAmountSB = value; iii
iii
private string qRYstring;

public string QRYstring
{
    get { return qRYstring; iii
    set { qRYstring = value; iii
iii

protected void Page_Load(object sender, EventArgs e)
{
    if (IsPostBack == false)
    {
        i++;
        this.PreRender += new EventHandler(Cast_PreRender);

        this.ID = "Result" + i.ToString();  


    iii
    PlayButton.ID = i.ToString();

iii

void Cast_PreRender(object sender, EventArgs e)
{
    PlayerName1.Text = Player1NameSB;
    PlayerName2.Text = Player2NameSB;
    CasterName.Text = CasterNameSB;
    ImageRace1.ImageUrl = Race1SB;
    ImageRace2.ImageUrl = Race2SB;
    Map.Text = MapSB;
    GameFrame.Text = GameFrameSB;
    LikeAmount.Text = LikeAmountSB;
    CasterLOGOIMG.ImageUrl = CasterLOGO;
    PlayButton.AlternateText = "yay";

iii
protected void PlayButton_Click1(object sender, ImageClickEventArgs e)
{

    Image img = (Image)sender;
    string tt = img.AlternateText;
    int j = 0;
    Response.Redirect("default2.aspx");
   // lb.Text = img.ClientID;

iii

iii

as页:

<asp:DataList ID="WatchLaterDL" runat="server" DataSourceID="SDSWatchLater" RepeatColumns="1">
                <HeaderTemplate>
                </HeaderTemplate>
                <ItemTemplate>
                    <Search:Bullet runat="server" EnableViewState="false" ID="SearchResults" Player1NameSB= <%#Bind("Player_Name") %> 
                        Player2NameSB= <%#Bind("Expr1") %>  CasterNameSB= <%#Bind("Caster_Name") %> 
                        Race1SB= <%#Bind("Race_1") %>  Race2SB= <%#Bind("Race_2") %>  MapSB= <%# Bind("Map")%> 
                        GameFrameSB= <%#Bind("Game_Frame") %>  LikeAmountSB= <%#Bind("Like_Amount") %> 
                        CastURLSB= <%#Bind("Cast_URL") %>  CasterLOGO= <%#Bind ("Caster_LOGO") %>  />
                </ItemTemplate>
                <SeparatorTemplate>
                    <br />
                </SeparatorTemplate>
            </asp:DataList></div>

问题在于,在这样做之后,当点击 but子时,就没有发生任何事情,也就是说,在偷窃时,就永远不会在奥布托顿内。 Click活动。 如果删除,则删除。 ID = “Result” + i.toString(); and the->EmButton。 ID = i.ToString();它 s。

if there anything elese you might need to evaluate my problem, ill gladly prove and additional code needed. thank you very much for your help.

最佳回答

我的解决办法是:

i 不是使用图像 but,而是使用超链接。

页: 1 用户控制线的Load事件,即分配给超链接的斜体,我的用户控制的所有特性,并通过那些使用超链接的人。

querystring to another page.

问题回答

核对数据清单的细目。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签