开发者

C# Added Ajax Update Panel but Anchor will not run server-side code once placeholder is populated

I've just been told I need to update my links from posting back so I added an Ajax Update Panel to handle the requests instead so there isn't a postback. My links are generated from the codebehind and popu开发者_运维问答late a placeholder. I need to update the code so that it will be able to run server side code. I have tried programmatically adding via controls.add but I couldn't get anything to run server side code.

                while (myReader.Read())
                {
                    try
                    {
                        eventListCounter++;
                        string strEventTitle = myReader["eventTitle"].ToString();
                        string strEventThumb = myReader["eventThumb"].ToString();
                        string strEventInfo = myReader["eventInfo"].ToString();
                        int eventID = Int32.Parse(myReader["ID"].ToString());
                        strHTML += "<div class='styleWeekRedCarpetEventBox'><div class='styleWeekRedCarpetPictureBox'>";
                        strHTML +="<a href='RedCarpet.aspx?eventID=" + eventID.ToString() +"'  runat='server' id='linkEventShowImageSet'><img Width='125' Height='95'src='Images/" + strEventThumb.ToString() + "' border='0'></a></div><div id='styleWeekRedCarpetPictureBoxText'><p><a href='RedCarpet.aspx?eventID=" + eventID + "' runat='server' id='linkEventShowImageSet'><b>" + strEventTitle.ToString() + "</b><br />" + strEventInfo.ToString() + "</a></p></div></div><br><br>";

                        if (eventListCounter == 5)
                        {
                            strHTML += "</div><div class=\"eventListColumn\">";
                            eventListCounter = 0;
                        }
                    }
                    catch (Exception strError)
                    {
                        Response.Write(strError.ToString());
                    }


                }
                LiteralControl eventListPlaceholder = new LiteralControl(strHTML.ToString());
                PlaceHolder2.Controls.Add(eventListPlaceholder);


This looks like the perfect place to use a repeater control, you should shy away from using Response.Write and let the framework abstract that away from you.

There is a high chance this this will solve the event not being fired server-side.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜