Showing posts with label following. Show all posts
Showing posts with label following. 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

ListSearchExtender

I trying to implement this on a page and get the following java error.

AjaxControlToolkit.Resources.ListSearch_DefaultPrompt is null or not an object

this is the code

<cc1:listsearchextenderid="ListSearchExtender1"runat="server"targetcontrolid="ddlmylist"PromptText="Type to search"PromptCssClass="ListSearchExtenderPrompt"PromptPosition="Top"></cc1:listsearchextender>

any ideas?

I've not seen this one before -- could you try hitting Shift-Refresh to be sure that you are getting all the latest JavaScript scripts into the browser. If it still doesn't work could you try creating a new test web site and seeing if that also fails? If it does could you possibly zip it up and send it to me?

Thanks,

Damian (ListSearch contributor)

ListView - whats the point?

The Tasklist sample has the following code (which doesn't seem to work):

<application>
<load>
<invokeMethodAction target="listsDataSource" method="load" />
</load>
</application>


Can anyone confirm that they can successfully run the Tasklist sample, add a couple of Lists, exit and re-run the sample and have the lists load at startup? This doesn't work for me.

Also, I'm confused by themethod="load" code. Previous docs and samples hadmethod="select" which I took to be matching theDataObjectMethodType.Select attribute on the web-service.

Either way, this code doesn't appear to work...

While I'm here, what exactly is the point of the ListView template control? It doesn't maintain itself over postbacks. Am I missing something here?

Confused of London, UK.

hello.

are you talking about the client side control?


Hi - thanks for the reply.

Yes, I'm talking about the xml-script ListView template control in the Preview. It's used in the TaskList sample. From what I can see, it doesn't render after a partial postback.


hello

the client ajax controls aren't supposed to maintain state between postbacks. with those controls, you should call web services in order to get data from the server side.

Saturday, March 24, 2012

Load on demand tabpanel

Hi there,

I wonder how to create some tabs with following requirement:
1. Load a tab's contain at the first times when it selected (except the first tab)
2. After the first load, you can chose another tab, and when you come back previous tab, it does not load again.

You can meet this requirement in "Related" Tab at 'New Post' page in this forum

Please help me by any link, artical, sample code, etc...

Thank you very much!

I'd like to do this too. Someone's gotta have a solution for this
I am also curious how this is done. It would be very useful to reduced the initial loading time of a page to not have to load the entire contents of the tabs before the page is presented to the user. I didn't see any OnActive event for TabPanels. Am I missing something?
OnActive event is not solution for this problem. It's?very easy when you want to create tabpanel with "Loading?style" on a tab actived. But, when you loaded a tab,?and?come?back?after?select?other?tab,?it will?load?again.

The main problem is: how to show loaded tab, but don't load again.
This is my solution for Tabpanel load tab on demand problem:
I create a Web method, which will return a string.
I call this method by Javascript (view Ajax tutorial at Asp.net)
In onComplete(arg) function, I saved return string (arg variable) in Javascript's variable.
On OnClientClick I call TryLoad javascript function to render my string to a div tab from memory

 /* Author: Do Quoc Khanh Email: doqkhanh@.gmail.com */ var flagArray=new Array(20); var contentArray = new Array(20); //Define var unLoaded = 0; var Loaded = 1; //Save current tabid var currentTab; var displayObj; function showValue(id, value) { document.getElementById(id).innerHTML = value; } function isFirstTime(currentTab) { if (flagArray[currentTab] == Loaded) { return true; } return false; } function tryLoad(displayobjectid, inputparam, tabid) { currentTab = tabid; displayObj = displayobjectid; if(isFirstTime(currentTab)) { //Fill info to obj value from memory showValue(displayObj,contentArray[currentTab]); } else { //Execute load process Test.GetCategories(inputparam, onComplete, onError, onTimeout); } } function onComplete(arg) { //Check loaded flag flagArray[currentTab] = Loaded; //Save to memory contentArray[currentTab] = arg; //Fill info to obj innerhtml from memory showValue(displayObj,arg); } function onError(arg) { alert('Error'); } function onTimeout(arg) { alert('Time out'); }