Showing posts with label believe. Show all posts
Showing posts with label believe. Show all posts

Wednesday, March 28, 2012

LinkButton OnCommand UpdatePanel

Somehow, the OnCommand method of a LinkButton never fires in the following code. I believe I'm running the latest of Ajax (1.0) and the Microsoft.Web.Preview.dll is there in my Bin directory. Any clue? I'm pretty sure I got this working when I didn't have UpdatePanel.

.ASPX code:

1<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">2 <asp:ScriptManager ID="ScriptManager1" runat="server">3 </asp:ScriptManager>4 <asp:UpdatePanel ID="up1" runat="server">5 <ContentTemplate>6 <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="false" Font-Size="X-Small"7 Width="100%" ShowHeader="false" BorderStyle="none">8 <RowStyle BackColor="#ffffff" />9 <Columns>10 <asp:ImageField DataImageUrlField="status" DataImageUrlFormatString="~/Images/{0}.png"11 NullDisplayText=" - " ItemStyle-HorizontalAlign="center" DataAlternateTextField="description" />12 <asp:TemplateField>13 <ItemTemplate>14 <asp:Literal runat="server" ID="appName" EnableViewState="false" Text='<%# Eval("app_name") + " (" + Eval("application_id") + ")"%>'></asp:Literal>15 </ItemTemplate>16 </asp:TemplateField>17 <asp:TemplateField ItemStyle-HorizontalAlign="center">18 <ItemTemplate>19 <asp:LinkButton runat="server" ID="linkPromote" Text='<%# this.GetLink(Convert.ToInt32(Eval("status")))%>'20 Visible='<%# this.ShowLink(Convert.ToInt32(Eval("status")))%>' OnClientClick="Ask();"21 CommandArgument='<%# Eval("application_id") + "|" + Eval("run_date") + "|" + Eval("status")%>'22 CommandName='<%# this.GetLink(Convert.ToInt32(Eval("status")))%>' OnCommand="ChangeStatus" />23 </ItemTemplate>24 </asp:TemplateField>25 <asp:TemplateField ItemStyle-HorizontalAlign="center">26 <ItemTemplate>27 <asp:HyperLink ID="details" runat="server" NavigateUrl='<%# "javascript:MasterList(" + this.GetRowData(Container) + ");"%>'28 ImageUrl="~/Images/more.gif" ToolTip="Details" Visible='<%# this.ShowDetails(Convert.ToInt32(Eval("status")))%>' />29 </ItemTemplate>30 </asp:TemplateField>31 </Columns>32 </asp:GridView>33 </ContentTemplate>34 </asp:UpdatePanel>35 <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" SelectMethod="GetListOfRunningAppsNotCompleted"36 TypeName="AnalyticsBizOb.StatusMonitorImp"></asp:ObjectDataSource>3738 <script type="text/javascript">39 function Ask()40 {41 return confirm('Are you sure you want to change status for this App?');42 }43 </script>4445</asp:Content>

Code-behind:

1protected void Page_Load(object sender, EventArgs e)2 {3if (!IsPostBack)4 {5 PopulateRunningAppsGrid();6 }7 }8void PopulateRunningAppsGrid()9 {10 ObjectDataSource2.SelectParameters.Clear();11 ObjectDataSource2.SelectParameters.Add("runDate","20070419");12 ObjectDataSource2.DataBind();13 GridView2.DataSourceID ="ObjectDataSource2";14 GridView2.DataBind();1516 }17protected void ChangeStatus(object sender, CommandEventArgs e)18 {19if (e.CommandName =="Restart" || e.CommandName =="Promote")20 {21 StatusMonitorImp smi =new StatusMonitorImp();22string[] args = e.CommandArgument.ToString().Split('|');23int statusTo = e.CommandName =="Restart" ? 19 : 20;2425 ScriptManager.RegisterStartupScript(up1, up1.GetType(),"success","alert('Successfully changed the status of app " + args[0] +" from " + args[2] +" to " + statusTo.ToString() +" for date " + args[1] +".');",true);2627 }28 GridView2.DataBind();29 }30public string GetRowData(IDataItemContainer iic)31 {32if (iic !=null)33 {34return DataBinder.Eval(iic.DataItem,"run_date").ToString() +", "35 + DataBinder.Eval(iic.DataItem,"application_id").ToString() +", '"36 + DataBinder.Eval(iic.DataItem,"app_name").ToString() +"'";37 }38else39 return"";40 }41protected bool ShowLink(int status)42 {43if (status == 19 || status == 50 || status == 500)44return true;45else46 return false;47 }4849protected bool ShowDetails(int status)50 {51if (status > 0 && status != 999)52return true;53else54 return false;55 }56protected string GetLink(int status)57 {58string ret ="";59if (status == 500 || status == 50)60 ret ="Restart";61if (status == 19)62 ret ="Promote";63return ret;64 }

Found the reason why it was not working. In my MasterPage, I've turn off the ViewState (EnableViewState = "false"), that's why the code above (OnCommand="ChangeStatus") was not firing up.

I don't know whether it is by design but I think it's bug in ASP.Net and something is not right in the core.

Monday, March 26, 2012

ListView / ItemView

Hi,

I wonder what happened to these controls.
If I take a look at thedocumentation I don't see them nor the Sys.UI.Data namespace where I believe they could be found in. Did that namespace and the underlying "controls" dissapear in favour of something else?

Also I heard at TechEd 2006 Barcelona that xml-script is likely to dissapear. Anyone knows what's going on about these?

Grz, Kris.

hello.

the las ttime i've looked, they were in the future bits, in the Sys.Preview.UI.Data namespace. xml-script is still there too, with lots of improvements when compared with the previous versions. i hope that, with time, they do add these features to the core bits...

So that's probably why I didn't find any documentation about it. Too bad. And yes I hope some of the CTP stuff gets into the Extensions pack as well.

Actually, which reflection tool do you use to take a peek into those namespaces?

Grz, Kris.


hello.

well, if you're speaking about the client side, then i don't use any. i just opne the js file a read it when i need something...

Hi,

you could check thisJavascript Class Browser byEilon Lipton. You should be able to browse also the types in the Futures CTP.


hello guys!

well, but you really don't want to loose the thrill of going through lines and lines of javscript, right?

Luis Abreu:

well, but you really don't want to loose the thrill of going through lines and lines of javscript, right?

No, I don't mind but first I need to get a better grasp of the Microsoft AJAX specific code. Yesterday I already did make a mistake with the $addHandler instead of add_EventName for which I apparently made the mistake to think that I should be using $addHandler. So first the basic steps before I can run. Thanks for all the help guys, really appreciate it.

Grz, Kris.


hello.

well, currently i think that there are one or two problems with the $addHandler (for instance, it doesn't work when you try to handle and event form a control maintained in another frame). however, i do believe that you should be using it in order to get browser independence error handling.