Showing posts with label inside. Show all posts
Showing posts with label inside. Show all posts

Wednesday, March 28, 2012

link button inside update panel causes post back

I have a linkbutton inside the update panel. I registered it with AsyncPostBackTrigger, but when I click that link button, the whole page is refreshed instead of that update panel, what could I have gone wrong?

Check the EnablePartialRendering="true" of ScriptManager is et or not ?

Also check UpdateMode="Conditional" of UpdatePanel is set or not ?

Link inside a draghandles template

Is it possible to access a link or a textbox inside a draghandle's template?

I want all the controls inside the draghandle to be dragable and also that users could click on these controls inside the draghandle

talking about ReorderList's DragHandle..

I"m trying to do a similar thing. Originally, I wanted to be able to drag any portion of a ReorderItem to a different position. The problem I ran into is that if you don't declare a position for the DragHandle, you can drag from any place on the ReorderItem BUT this means you cannot click on any controls that are contained in the ReorderItem, making them all useless. The control thinks that if you click ANYWHERE, you're trying to drag it, so the controls can never be used.

So, to remedy this problem, I thought to do exactly what you're doing. I added a <DragHandle> to the left side which contains a Label; this Label was to hold the sequence number of the ReorderItems (so the first item would have a 1, the second would contain a 2, etc), but like you I cannot access this control from the code behind when the Reorder event fires.


your problem seems diferent than mine. I don't have any problems accesing controls in the code behind. I'm trying to figure out how to make some parts of the draghandle dragable and some of them "clickable". I guess i need to construct some <div> element consisting of several other <div> elements and put a draghandle inside one of them. But here is another problem: you cannot place the draghandle anywhere you like, just four possitions. So i cannot put it inside a particular <div> element

I guess i need to think another way to do it

link usage by ajax framework

HI, I am new using ajax... so..I created a small project with a few controls inside a page.I was doing well every think fine.So I started a web test project to see the impact of using ajax inside my page (link usage)...and what I see was a use of a "library" off size 250Kb ...Is this correct I doing something wrong ?

The controls that I was testing was part off the toolkit

Hi,

According to my understanding, you noticed a .js file with size of 250 KB was downloaded.

This is the correct behavior. Actually, AJAX is implemented with javascript, which will be responsible for sending request asynchronously, update contents on the web form. And there are also a lot auxiliary methods and objects.

So, it's normal to see this.

Just pay attention to changing the debug mode to false in web.config before you are going to deploy your application.


I would like to know if this .js will be downloaded at each post in the page? For navigation between different pages that use Ajax technology .js will be downloaded several times? What I expected is that .js was to be downloaded only once. But my tests don't show this! Am I correct? Or I am loosing something Thank you Very Much

You need to set debug to false in web.config.

LinkButton & UpdatePanel

I have dynamically added a linkbutton inside of an updatepanel. For some reason that I don't understand when I click on the linkbutton the entire page refreshes. I can't figure out why. It's in a content page which uses a master page. I've tried using Conditional & Always. I've tried adding anAsyncPostBackTrigger for the linkbutton Click, but no matter what the entire page refreshes. If I use a non-dynamically added linkbutton (see LinkButton1 below) it only updates the updatepanel. Any ideas?

Here are some code snippets:

<asp:UpdatePanel ID="FlyoutUpdate" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="pnlSingleCalItem" runat="server" Height="270px" Width="350px">
<asp:Label ID="lblDateHeader" runat="server" Text="test"></asp:Label>
<br /><br />
<table width="100%">
<tr><td align="left" style="background-color:#E6E7E8">
<asp:Label ID="lblCalTitle" Font-Bold="true" Font-Size="13px" Font-Names="Arial" ForeColor="#96B96E" runat="server" Text="Title"></asp:Label>
<br />
<asp:Label ID="lblCalLocation" runat="server" Font-Size="12px" Font-Names="Arial" ForeColor="#BA906C" Text="Location"></asp:Label></td></tr>
<tr><td align="left"><asp:TextBox BorderWidth="0px" BorderStyle="none" Font-Size="11px" Font-Names="Arial" ID="txtCalMessage" runat="server" Width="350px" Height="200px" TextMode="multiLine"></asp:TextBox></td></tr>
</table>
</asp:Panel>
<asp:Panel ID="pnlMultipleCalItems" runat="server" Height="270px" Width="350px">
<asp:Label ID="lblDateHeaderMulti" runat="server" Text="test"></asp:Label>
<br /><br />
<asp:Table ID="tblMultipleCalItems" BorderWidth="0px" BorderStyle="none" runat="server">
</asp:Table>
<br /><br />
<asp:LinkButton ID="LinkButton1" runat="server">LinkButton</asp:LinkButton>
</asp:Panel>

</ContentTemplate>
</asp:UpdatePanel>

Dim hypAs New LinkButtonhyp.Text = varNameAddHandler hyp.Click,New EventHandler(AddressOf hyp_Click)hyp.Visible = varVisibleDim trAs New TableRow()Dim td1As New TableCell()td1.Controls.Add(hyp)Dim tblAs Tabletbl = pnlMultipleCalItems.FindControl("tblMultipleCalItems")tr.Cells.Add(td1)tbl.Rows.Add(tr)

Hi

When you add something to the page dynamically,you should add it everytime the page been posted back.

If you don't add it again when the page been Ayncpostbacked,the contorl is null,and it's click event handler method isn't executed.

Thanks


Hi Jim-Yu,

That is a good idea, but NO... LinkButton as a child control of a custom control causes a PostBack not a Callback. Here's some sample code the shows the bug in LinkButton. Put this custom control on an UpdatePanel and notice the "button" does a nice callback, and the "link" does a postback.

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace testing
{
/// <summary>
/// Summary description for Test
/// </summary>
public class Test : Control, INamingContainer
{
public Test()
{
//
// TODO: Add constructor logic here
//
}

protected override void CreateChildControls()
{
CreateThem();
base.CreateChildControls();
}

protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
}

private void CreateThem()
{
LinkButton lnk = new LinkButton();
lnk.Text = "link";
Button btn = new Button();
btn.Text = "button";

this.Controls.Add(btn);
this.Controls.Add(lnk);
}
}
}


Hincornillon,

Thank you for your feedback,

You can change your code to:

private void CreateThem()
{
LinkButton lnk = new LinkButton();
this.Controls.Add(lnk);
lnk.Text = "link";
ScriptManager.GetCurrent(this.Page).RegisterAsyncPostBackControl(lnk);

Button btn = new Button();
this.Controls.Add(btn);
btn.Text = "button";
// ScriptManager.GetCurrent(this.Page).RegisterAsyncPostBackControl(btn);
}

Best Regards


I'm afraid it's still not working. When I dynamically create the controls I'm putting them in a Session array. Then in page_init I'm re-generating them like this below. When I'm looping through the Request.Form, I never see the link button.

If Session("ServerControls")IsNotNothingThen
aServerControls =TryCast(Session("ServerControls"), ArrayList)
Else
aServerControls =New ArrayList()
EndIf

ForEach strAsStringIn aServerControls
Dim hypAsNew LinkButton
Dim hypNameAsString = str
hypName = Replace(hypName,"/","_")
hyp.Text = hypName
AddHandler hyp.Click,New EventHandler(AddressOf hyp_Click)
pnlMultipleCalItems.Controls.Add(hyp)
ScriptManager.GetCurrent(Me.Page).RegisterAsyncPostBackControl(hyp)
Next

'Detect what caused the postback
Dim obj
ForEach objIn Request.Form

Next


Since there is a limited amount of controls to create, I manually created them and am just setting them either visible or not. It was faster. Thanks for the help!

Linkbutton inside atlas:UpdatePanel

Hi All,

I am having few linkbuttons inside an atlas:UpdatePanel. I have placed these inside UpdatePanel as I have to regularly change the text of this linkbuttons.

When I click on these linkbuttons it is actually supposed to update a DataGrid which is placed outside atlas:updatepanel, but in same page. When I debug and see, the Onclick code for the Linbutton is called and also the code necessary to update the Datagrid is also executed. But for some reason, in display the Datagrid is not changing. Is this got something to do with the positioning of grid in page? it is outside updatepanel.

I will copy the required parts of code here . Please help.

In aspx page :

<atlas:TimerControl ID="tmrUpdate" runat="server" Enabled="true" Interval="300000" OnTick="SetIndicatorCount"></atlas:TimerControl>
<atlas:UpdatePanel ID="pnlUpdate" RenderMode="Inline" runat="server">
<ContentTemplate>
<table style="background-color:whitesmoke;font-size:smaller" cellpadding="2" cellspacing="0">
<tr class="DisplayHeader">
<td class="DisplayHeader" colspan="4" align="left">
<asp:Label ID="Label2" runat="server" Text="Driver Exceptions"></asp:Label>
</td>
</tr>
<tr>
<td style="height: 19px">
<cc1:LinkButton ID="lnkTrainersAvailable" Text = "Trainers Available" runat="server" OnClick="lnkTrainersAvailable_Click" ></cc1:LinkButton>
</td>
<td style="height: 19px">
<cc1:LinkButton ID="lnkServiceExceptions" Text="Service Exceptions" runat="server" OnClick="lnkServiceExceptions_Click"></cc1:LinkButton>

</td>
<td style="height: 19px">
<cc1:LinkButton ID="lnkUnreadMessages" Text = "Unread Messages" runat="server" OnClick="lnkUnreadMessages_Click"></cc1:LinkButton>
</td>
<td style="height: 19px">
<cc1:LinkButton ID="lnkHoursNotIn" Text="Hours Not In" runat="server" OnClick="lnkHoursNotIn_Click" ></cc1:LinkButton>
</td>
</tr>

<tr>
<td>
<cc1:LinkButton ID="lnkDriversAvailable" Text = "Drivers Available" runat="server" OnClick="lnkDriversAvailable_Click"></cc1:LinkButton>
</td>
<td>
<cc1:LinkButton ID="lnkContactDue" Text = "Contacts Due" runat="server" OnClick="lnkContactDue_Click" ></cc1:LinkButton>

</td>
<td>
<cc1:LinkButton ID="lnkMaintenanceDue" Text = "Maintenance Due" runat="server" OnClick="lnkMaintenanceDue_Click" ></cc1:LinkButton>
</td>
<td>
<cc1:LinkButton ID="lnkFreeTimeExpired" Text = "Free Time Expired" runat="server" OnClick="lnkFreeTimeExpired_Click" ></cc1:LinkButton>
</td>
</tr>
<tr>
<td style="height: 19px">
<cc1:LinkButton ID="lnkMissedCalendars" Text = "Calendar Due" runat="server" Enabled="true" OnClick="lnkMissedCalendars_Click"></cc1:LinkButton>
</td>
<td style="height: 19px">
<cc1:LinkButton ID="lnkDriverWorkflowRequired" Text = "Driver Workflow Req." runat="server" Enabled="false"></cc1:LinkButton>
</td>
<td style="height: 19px">
<cc1:LinkButton ID="lnkTrackingEarly" Text = "Tracking Early" runat="server" OnClick="lnkTrackingEarly_Click" ></cc1:LinkButton>
</td>
<td style="height: 19px">
<cc1:LinkButton ID="lnkCurrentDeliveries" Text="Current Deliveries" runat="server" OnClick="lnkCurrentDeliveries_Click" ></cc1:LinkButton>
</td>
</tr>
<tr>

<td>
<cc1:LinkButton ID="lnkDetention" Text = "Detention Pay" runat="server" OnClick="lnkDetention_Click"></cc1:LinkButton>
</td>
<td>
<cc1:LinkButton ID="lnkSafteyFollowUp" Text = "Safety Follow up/Audit" runat="server" Enabled="false"></cc1:LinkButton>

</td>
<td>
<cc1:LinkButton ID="lnkTrackingLate" Text = "Tracking Late" runat="server" OnClick="lnkTrackingLate_Click" ></cc1:LinkButton>
</td>
<td>
<cc1:LinkButton ID="lnkDiaryFollowUp" Text = "Diary Follow Up" runat="server" OnClick="lnkDiaryFollowUp_Click"></cc1:LinkButton>
</td>


</tr>
</table>
</ContentTemplate>
<Triggers>
<atlas:ControlEventTrigger ControlID="tmrUpdate" EventName="Tick" />
</Triggers></atlas:UpdatePanel>
<tr>
<td colspan="2">
<uc1:grdDriverCurrentInformationDisplay ID="_grdDriverCurrentInformationDisplay" runat="server" ></uc1:grdDriverCurrentInformationDisplay>
</td>
</tr>

Actually the grid is inside the User control, grdDriverCurrentInformationDisplay.

In aspx.cs the code for Linkbutton clicks which are inside updatepanel are there :

protectedvoid lnkHoursNotIn_Click(object sender,EventArgs e)

{

try

{

lblDrivers.Text ="Hours Not in Drivers ";this.LoadDriverIndicators(RTI.DataLayerV2.RTIDriver.DMDriverIndicator.MessagingIndicatorTypeEnum.HoursNotIn);

}

catch (RTI.FrameworkV2.BrokenRulesException bex)

{

this.Messages = bex.Messages;

}

}

////One method used to retreive the information for the supervisor codes, where clause and indicator typepublic void LoadDriverIndicators(RTI.DataLayerV2.RTIDriver.DMDriverIndicator.MessagingIndicatorTypeEnum indicatorType) {//retrieves the correct supervisorcodes and the where cluase from the grid where they stored in a hidden text boxstring supervisor =this._grdDriverCurrentInformationDisplay.GetSupervisorCode();string whereClause =this._grdDriverCurrentInformationDisplay.GetWhereClause();if (String.IsNullOrEmpty(supervisor))throw new Exception("Must enter a supervisor code");//If the messages are choosen it loads the drivers with unreadmessages from the communication system //otherwise the indicators are loaded from the driver database //Each time a link button is clicked the information is retrieved nothing is stored in view state RTI.Business.DriverManagement.DriverInfo.DriverIndicator indicator =new RTI.Business.DriverManagement.DriverInfo.DriverIndicator(); List indicatorList =new List();if (indicatorType == RTI.DataLayerV2.RTIDriver.DMDriverIndicator.MessagingIndicatorTypeEnum.UnreadMessages) { indicatorList = FleetManager.FillGrid.GetDriverInformationRows(indicator.LoadDriverInformationForUnreadMessage(supervisor, whereClause, RTI.CommonV2.Constants.CommunicationMessageCodes.FreeForm)); }else if (indicatorType == RTI.DataLayerV2.RTIDriver.DMDriverIndicator.MessagingIndicatorTypeEnum.ServiceExceptions) { indicatorList = FleetManager.FillGrid.GetDriverInformationRows(indicator.LoadDriverInformationForServiceExceptions(supervisor, whereClause)); }else if (indicatorType == RTI.DataLayerV2.RTIDriver.DMDriverIndicator.MessagingIndicatorTypeEnum.DiaryFollowUp) { indicatorList = FleetManager.FillGrid.GetDriverInformationRows(indicator.LoadDriverInformationForDiaryFollowup(supervisor, whereClause)); }else { indicatorList = FleetManager.FillGrid.GetDriverInformationRows(indicator.LoadDriverInformationAndIndicator(supervisor, whereClause, indicatorType));if (indicatorType == RTI.DataLayerV2.RTIDriver.DMDriverIndicator.MessagingIndicatorTypeEnum.TrackingLate) { indicatorList.Sort(delegate(FleetManager.FillGrid.DriverInformation d1, FleetManager.FillGrid.DriverInformation d2) {return d1.LateMinutes.CompareTo(d2.LateMinutes); }); indicatorList.Reverse(); } }this._grdDriverCurrentInformationDisplay.ClearGrid();if (indicatorList.Count > 0) { RTI.Business.DriverManagement.DriverInfo.DriverIndicator indicators =new RTI.Business.DriverManagement.DriverInfo.DriverIndicator(); RTI.DataLayerV2.RTIDriver.DMIndicatorCountDataTable table = indicators.LoadIndicatorCount(supervisor, whereClause);for (int k = 0; k < table.DataTable.Rows.Count; k++) { table.Index = k;if (table.IndicatorType == Convert.ToInt32(RTI.DataLayerV2.RTIDriver.DMDriverIndicator.MessagingIndicatorTypeEnum.HoursNotIn)) {if (indicatorType == RTI.DataLayerV2.RTIDriver.DMDriverIndicator.MessagingIndicatorTypeEnum.HoursNotIn) {int hoursCount = 0;for (int i = 0; i < indicatorList.Count; i++) {if (indicatorList[i].HomeCity.ToString().Trim().Replace(" ",string.Empty).Trim() == indicatorList[i].DestinationLocation.ToString().Trim().Replace(" ",string.Empty).Trim()) { indicatorList.Remove(indicatorList[i]); i--; hoursCount++; } }//RTI.Business.DriverManagement.DriverInfo.DriverIndicator indicators = new RTI.Business.DriverManagement.DriverInfo.DriverIndicator(); //RTI.DataLayerV2.RTIDriver.DMIndicatorCountDataTable table = indicators.LoadIndicatorCount(supervisor, whereClause);int count = Convert.ToInt32(table.Total) - hoursCount; lnkHoursNotIn.Text = String.Format("Hours Not In ({0})", count); } } }this._grdDriverCurrentInformationDisplay.LoadByDriver(indicatorList, indicatorType);this.lblDrivers.Text += indicatorList.Count.ToString(); }else {this.AddFeedbackMessage("There are no Drivers that qualify for the indicator"); } }

Please tell why the grid is not updated.

Regards,

Allen.

It's not getting updated because it's not in an updatepanel, and ithe page is not doing a full postback. Read up on update panels at ajax.asp.net/docs to see how the partial page rendering model works.


Is it that I have to include the user control which is having the DataGrid also inside The atlas:UpdatePanel? As Linkbutton's functionality is entirely different why is it required that grid also be in the Updatepanel. It's not a problem even if the entire page refreshes on click of linkbutton.

Please advise.


No, it doesn't have to be in the same updatepanel, just *an* updatepanel. your other option is to set the linkbutton up as a postback control (which tells the updatepanel to go ahead and post the whole page back even though it's inside the updp).


Enabling Partial-Page Updates

TheUpdatePanel control requires aScriptManager control in the Web page. By default, partial-page updates are enabled because the default value of theEnablePartialRendering property of theScriptManager control istrue.

The following example shows markup that defines aScriptManager control and anUpdatePanel control on a page. TheUpdatePanel control contains aButton control that refreshes the content inside the panel when you click it. By default, theChildrenAsTriggers property istrue. Therefore, theButton control acts as an asynchronous postback control.

You have to set LinkButtons PostBack property, so it postbac the page.

http://ajax.asp.net/docs/overview/UpdatePanelOverview.aspx

Linkbutton inside accordionPane header

Hello.

I have an accordion with some panes. In panes header I have a text and a linkbutton. I want to open a pane when user clicks on text, but I don't want to open (or close) the pane when user clicks on linkbutton. When user clicks linkbutton the pane must not move.

Anyone knows how can I do it?

Thanks!!! and sorry for my english (greetings from Spain! :D)


I would also like to know. Looking at the source code I cant seem to find anything short of re-writing in javascript a number of functions.

Rather disappointed with the level of support for these kind of things this control has.


Please someone can help us? :-(


Hi,

The reason and solution has been discussed in this post: http://forums.asp.net/p/1133424/1809338.aspx

Please try it.


I searched before but i didn't find it.

THAT WORKS!!!


THANK YOU A LOT!Cool

LinkButton inside a repeater as a trigger

 I have been searching all over for an answer but have yet to find anything. 

I have a repeater that I use to display a letter paging system. It looks something like this

<asp:Repeater ID="rpt_Letters" runat="server"> <ItemTemplate> <asp:LinkButton ID="lbtn_Letter" CausesValidation="false" CommandName="Filter" CommandArgument='<%# Eval("Letter") %>' runat="server" style="padding-left:7px; padding-top: 10px;" ToolTip='<%# Eval("Letter") %>'><%# Eval("Letter") %></asp:LinkButton> </ItemTemplate> </asp:Repeater>

Once a letter is clicked I want to update the information in a GridView.

I have the GridView in an update panel, but I can't find away to set my Letter Paging as a trigger.

Thank You!


.csharpcode, .csharpcode pre{font-size: small;color: black;font-family: Consolas, "Courier New", Courier, Monospace;background-color: #ffffff;/*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt {background-color: #f4f4f4;width: 100%;margin: 0em;}.csharpcode .lnum { color: #606060; }
Add your repeater control to an UpdatePanel as follows:<asp:UpdatePanelID="PagingPanel"UpdateMode="Conditional"runat="server"><ContentTemplate><asp:RepeaterId="">...</asp:Repeater>and put your gridview control in another UpdatePanel like this:<asp:UpdatePanelID="OrderDetailsPanel"UpdateMode="Always"runat="server"><ContentTemplate><asp:gridview/>And then add handler for OnCommand event of the linkbutton (lbtn_Letter) where you can filter rows like this:protected void Letter_OnCommand(object sender, CommandEventArguments e) { SqlDataSource2.SelectParameters["OrderID"].DefaultValue = e.CommandArgument ;SqlDataSource2.DataBind();}where SqlDataSource2 is bound to your GridView control.That's it.

Thanks!

Linkbutton inside update panel not working and causing exception

I page that contains an update panel. this page has a linkbutton that redirects to a new page and opens that page in a a new window(the page redirected to displays a picture). This linkbutton has been working all along with after adding this line of code in the pageload event.

ScriptManager.GetCurrent(Page).RegisterPostBackControl(LinkButton23)

suddenly, the linkbutton can nolonger redirect to the page when clicked and iam not aware of anything i did that may have crewed it up. I now get the following error message when i click it.

sys.webforms.webrequestmanagerParsererrorException: The message recieved from the server could not be parsed . Common causes for this error are when the response is modified by calls to response.write(), response.filters or server trace is enabled. Details: Error parsing near '<script language="ja'.

Actually i have noticed very strange behaviours by my IDE since i installed windows updates on tuesday, things like button click events not firing.

Any help.

Iam not sure if this extra information may help me get a reply. After some googling, most results are pointing to some thing to do with response.write in an update panel.

And in side the click event of my linkbutton, i have these javascript lines of code

ProtectedSub LinkButton23_Click1(ByVal senderAsObject,ByVal eAs System.EventArgs)

Dim myScriptAsString ="<script language=""javascript"">window.open('human Resources/viewer.aspx?id=" + employeenumber.SelectedValue +"') </" +"script>"

Response.Write(myScript)

EndSub

Iam not sure if this could be the cause of the problem but just in case.


<%@.PageLanguage="VB"AutoEventWireup="false" %>

I just changedAutoEventWireup from ="false" to="true" and every thing is back to normal, makes look stupid after wasting loosing over 8 hours. One more gotcha learnt though.

Linkbutton not working, Imagebutton OK

I placed a usercontrol inside an updatepanel.

The usercontrol has a placeholder, and to that placeholder I add imagebuttons and linkbuttons.

When the imagebuttons are clicked, a partial update of the page is done = GOODSmile

When an linkbutton is clicked, a full update of the page is done = BADAngry (No javascript errors whatsoever).

Does asp.net ajax treat this two types of controls differently? Did I forget to do extra steps?

Regards,

Fizgig



Does anyone have a solution for this? I'm getting the same results with a <asp:LinkButton>. When I try with <asp:Button>, it works perfectly.

This works for me.

<formid="form1"runat="server"><asp:ScriptManagerID="ScriptManager1"runat="server"/><asp:UpdatePanelID="UpdatePanel1"runat="server"UpdateMode="Conditional"><ContentTemplate><asp:PlaceHolderID="PlaceHolder1"runat="server"><asp:ImageButtonID="ImageButton1"ImageUrl="Untitled-1.gif"runat="server"/><br/><br/><asp:LinkButtonID="LinkButton1"runat="server">LinkButton</asp:LinkButton><br/><br/></asp:PlaceHolder><asp:LabelID="lblTest"runat="server"Text="Label"></asp:Label></ContentTemplate></asp:UpdatePanel><div><asp:LabelID="lblTest2"runat="server"Text="Label"></asp:Label></div></form>

Hi Fizgig,

I tried dynamic imageButton, it works fine.

See this:

using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;public partialclass Ajax_Default2 : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e) { LinkButton lb =new LinkButton();this.PlaceHolder1.Controls.Add(lb); lb.Text ="Linkbutton"; lb.ID ="lb1"; lb.Click +=new EventHandler(lb_Click); ImageButton ib =new ImageButton();this.PlaceHolder1.Controls.Add(ib); ib.ID ="ib1"; ib.ImageUrl ="~/images/add.gif"; ib.Click +=new ImageClickEventHandler(ib_Click); Label2.Text = DateTime.Now.ToString(); }void ib_Click(object sender, ImageClickEventArgs e) { Label1.Text ="ib1 clicked on " + DateTime.Now.ToString(); }void lb_Click(object sender, EventArgs e) { Label1.Text ="lb1 clicked on " + DateTime.Now.ToString(); }}

<asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder> <br /> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </ContentTemplate> </asp:UpdatePanel> <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>

Maybe it's fixed in the current Ajax version. Thanx.

I am receiving the same error that was reported in the original post. In my case I have a link button and an image button and so I'm able to hack this together by setting the OnClientClick property of the LinkButton to <%# "document.getElementById('" + Thumbnail.ClientID + "').click();return false;" %> - which is not very elegant, but works fine. Hopefully later I'll have a chance to better isolate this issue - I've run into it a couple times, but am not sure what the variable is yet.


I found that you have to add a trigger for the link button, so here's what you have to add, where lb is my linkbutton, and upPanel is the update panel that contains the link button...

AsyncPostBackTrigger asbt = new AsyncPostBackTrigger();
asbt.ControlID = lb.ID;
asbt.EventName = "Click";
upPanel.Triggers.Add(asbt);


Good find. That makes sense - although it's peculiar that it works different for the LinkButton and ImageButton. Thanks for posting that.

LinkButton OnClick not firing inside UpdatePanel

I have a page with a MultiView containing 2 views. The second view has a number of LinkButtons which implement a menu. I have wrapped the MultiView inside an UpdatePanel. The problem that I am having is that the events (specifically OnClick) don't fire for the LinkButtons. If I replace the LinkButtons with a Button everything works fine. I am doing something wrong or is there a problem with LinkButtons?I'm having the same issue right now. In an earlier version I had this working, so I'm not quite sure what happened.
I looked into it a bit farther and the postback function seems to be missing from the javascript for the page. I switched to MagicAjax and now everything works the way it is supposed to.
I'm a little too deep to make any switches. :-)

hello.

let me see if i understand what's going: you have a multiview control and in one of the views you have several linkbuttons. clicking on the button doesn't postback and from what you say, the problem is that the postback method isn't in the page.

so, i assume that the view that has the buttons isn't the initial view and that you don't have anything on that page that is able to start a postback. if this is your scenario, then the problem you're seeing is a bug of the atlas platform. the problem is that during partial postbacks, the __doPostBack is discarded and isn't added on the client side because the platform assumes that it is alread there.

an easy workaround is to add a button to the page (with the usesubmitbehavior set to false) and hide it (by using the css display property).btw, the reason everything worked with buttons is because on asp.net 2, they are inserted as submit buttons by default (<input type="submit">).


I guess my problem is a little simplier. I have two LinkButton objects inside of a Panel object, which is then contained in an UpdatePanel. To test, I added a Button object and it does postback as expected. The LinkButtons do not postback and I cannot figure out why. Is this a known issue with Atlas?

hello.

it looks like you can reproduce the problem with a simple page...can you post that page here?


The problem was the panel being set to "visible = false" up front. I have a link on the page that sets it to be visible though. Once that link is clicked and the panel is visible, the two LinkButtons don't fire the postbacks. Instead, when I started up with visible being set to true, everything worked just fine. So I just had to do a little z-index magic to get around setting it to "visible = false" to start. Kind of weird I can't start with that panel not being visible.

hello.

well, that's the problem i've described in my previous post. the same thing happens when you put the button inside a panel and set it its visible property to false during the initial rendering of the page. in these cases, when you don't have any other controls that use the __doPostBack method, the page won't work correctly when you use partial postbacks because even though the server side sends the __doPostBack method on the reponse for a partial postback, it'll be discarded by the client framework since it allways assumes that the method was added to the page during its initial rendering.

this is an old bug that i've reported a few months ago, though it still hasn't been solved.


Thank god for this thread, I finally able to solve the problem that I've been trying to solve for days. Your solution does work for panels and/or linkbutton inside the updatepanel. However, when I tried to set the visibility of the panel located outside of the updatepanel to true (initially set to false) by calling a method, it does not work. Any workaround for this? Thanks a bunch!

hello.

are you doing that (changing the visibility of the panel) during a partial postback? if so, then the panel must be inside an updatepanel...


Umm ... well, I don't know .. Am I? Anyhow, this is the code:

<asp:Content ID="Content1" ContentPlaceHolderID="Main" runat="Server"> <cc1:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"> </cc1:ScriptManager> <div id="comments" class="page"> <table> <tr> <td> <asp:Label ID="Label1" runat="server" Text="Name"></asp:Label></td> <td> <asp:TextBox ID="Nama" runat="server"></asp:TextBox></td> </tr> <tr> <td> <asp:Label ID="Label2" runat="server" Text="Comment" Style="vertical-align: top"></asp:Label></td> <td> <asp:TextBox ID="Komen" runat="server" Height="72px" Width="299px"></asp:TextBox></td> </tr> <tr> <td> <asp:Button ID="Button1" runat="server" OnClick="SubmitComment" Text="Submit" /></td> <td><asp:Label Visible=false ForeColor=red ID=commentError runat=server></asp:Label></td> </tr> </table> <br /> <cc1:UpdatePanel ID="UpdatePanel1" runat="server" Mode="Conditional"> <ContentTemplate> <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataSourceID="SqlDataSource1"> <Columns> <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" /> <asp:BoundField DataField="Comment" HeaderText="Comment" SortExpression="Comment" /> <asp:BoundField DataField="Date" HeaderText="Date" SortExpression="Date" /> </Columns> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString%>" SelectCommand="SELECT Name, Comment, Date FROM Comments ORDER BY Date DESC"></asp:SqlDataSource> </ContentTemplate> <Triggers> <cc1:ControlEventTrigger ControlID="Button1" EventName="Click" /> </Triggers> </cc1:UpdatePanel> </div></asp:Content>
and this is the codebehind that validate the input:

public void SubmitComment(Object sender, EventArgs e) { String dt = DateTime.Now.ToString(); String Name = Nama.Text; String Comment = Komen.Text;if (Name =="" || Comment =="") { commentError.Text ="Please complete all required fields"; commentError.Visible =true; }else {//SOME CODE TO INSERT Name and Comment to database } }
So, basically if the user doesn't put either name or comment, the commentError label will be shown up. Should I just put the entire table into update panel? Because when the Button1 is not tied up to the triggers, everything works fine.

hello.

well, that's because when button1 is configured as a trigger, the client portion of atlas intercpets the call and performs a partial postback; when you don't do that, you get a full postback. so, you have 2 options: you can put everything inside a panel or you can use two panels.

LinkButton Trigger inside a repeater

 I have been searching all over for an answer but have yet to find anything. 

I have a repeater that I use to display a letter paging system. It looks something like this

<asp:Repeater ID="rpt_Letters" runat="server"> <ItemTemplate> <asp:LinkButton ID="lbtn_Letter" CausesValidation="false" CommandName="Filter" CommandArgument='<%# Eval("Letter") %>' runat="server" style="padding-left:7px; padding-top: 10px;" ToolTip='<%# Eval("Letter") %>'><%# Eval("Letter") %></asp:LinkButton> </ItemTemplate> </asp:Repeater>

Once a letter is clicked I want to update the information in a GridView.

I have the GridView in an update panel, but I can't find away to set my Letter Paging as a trigger.


Hi,

an approach could be wrapping the repeater with an UpdatePanel with UpdateMode="Conditional" and ChildrenAsTriggers="false". This won't make the panel update when a LinkButton is clicked, but will trigger an asynchronous postback where you can update the panel that contains the GridView. Check this basic example:

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { repTriggers.DataSource = new int[3] { 0, 1, 2 }; repTriggers.DataBind(); } } protected void repTriggers_ItemCommand(object sender, RepeaterCommandEventArgs e) { if (e.CommandName == "trigger") { LinkButton btn = e.CommandSource as LinkButton; if (btn != null) { lblUpdate.Text = "Update triggered by " + btn.ID + e.Item.ItemIndex.ToString(); } UpdatePanel2.Update(); } }</script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="TheScriptManager" runat="server"></asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="false" UpdateMode="conditional"> <ContentTemplate> <asp:Repeater ID="repTriggers" runat="server" OnItemCommand="repTriggers_ItemCommand"> <ItemTemplate> <asp:LinkButton ID="lnkTrigger" runat="server" Text="Trigger" CommandName="trigger"></asp:LinkButton> </ItemTemplate> </asp:Repeater> </ContentTemplate> </asp:UpdatePanel> <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="conditional"> <ContentTemplate> <asp:Label ID="lblUpdate" runat="server"></asp:Label> </ContentTemplate> </asp:UpdatePanel> </form></body></html>

Good suggestion, Garbin, but I think I have an even easier way. You can simply add your Repeater as a trigger for your UpdatePanel. Here's my version, with comments indicating where it differs from Garbin's:

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { repTriggers.DataSource = new int[3] { 0, 1, 2 }; repTriggers.DataBind(); } } protected void repTriggers_ItemCommand(object sender, RepeaterCommandEventArgs e) { if (e.CommandName == "trigger") { LinkButton btn = e.CommandSource as LinkButton; if (btn != null) { lblUpdate.Text = "Update triggered by " + btn.ID + e.Item.ItemIndex.ToString(); } // [Steve] removed UpdatePanel2.Update() } }</script><html xmlns="http://www.w3.org/1999/xhtml" ><head id="Head1" runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="TheScriptManager" runat="server"></asp:ScriptManager><%-- [Steve] removed UpdatePanel1 --%> <asp:Repeater ID="repTriggers" runat="server" OnItemCommand="repTriggers_ItemCommand"> <ItemTemplate> <asp:LinkButton ID="lnkTrigger" runat="server" Text="Trigger" CommandName="trigger"></asp:LinkButton> </ItemTemplate> </asp:Repeater> <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="conditional"><%-- [Steve] added repTriggers as an AsyncPostBackTrigger --%> <Triggers> <asp:AsyncPostBackTrigger ControlID="repTriggers" /> </Triggers> <ContentTemplate> <asp:Label ID="lblUpdate" runat="server"></asp:Label> </ContentTemplate> </asp:UpdatePanel> </form></body></html>

Hi,

yes, definitely :)


Thank you!

That was too easy! I can't believe I never tried that.Embarrassed

LinkButtons programmically added to updatepanel click event not firing

I have a conditional updatepanel with a multiview control inside. The first view displays a list of items in a table with a linkbutton next to each one created programmically with an eventhandler for the click event. The click event changes the multiview's active view to the next view to display controls for editing that item. The item table's content is first initialized in the OnLoad() function inside a if(!isPostback). I plan to eventually have a save button in the second view that will update the table's content after that. (ScriptManager EnablePartialRender = "true").

Ex:

    for(int i = 0; i < itemcount; i++) { ... LinkButton itemedit = new LinkButton(); itemedit.Text = "Edit"; itemedit.Click += new EventHandler(itemedit_Click); table.Controls.Rows[i].Cells[1].Add(itemedit); ...}

When I view the page and click the linkbutton next to one of the items in the updatepanel it starts to update. However, the view never changes. Further tests have shown that the click event is never being handled. If I change the code so that the table is updated during initial load and postbacks, I can get the click event to fire once. After the multiview is goes back to the original view, the click event can no longer be raised until the whole page is reloaded.

So, what I am trying to figure out is how to create eventhandlers at runtime inside an updatepanel and getting them to fire on an update.

Well, I have found a solution. I desided to scale the problem down to the most basic functions by creating a test application containing an updatepanel, multiview control with two views, and some code in the background to create a linkbutton to switch from one view to the other. The page looks like this as generated by VS:

<%@. Page Language="C#" AutoEventWireup="true" CodeFile="dynamicevent.aspx.cs" Inherits="dynamicevent" %
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="True">
</atlas:ScriptManager>

</div>
<atlas:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
<asp:View ID="View1" runat="server">
view1</asp:View>
<asp:View ID="View2" runat="server">
view2</asp:View>
</asp:MultiView>
</ContentTemplate>
</atlas:UpdatePanel>
</form>
</body>
</html>

The page is pretty basic and so is the code behind:

public partialclass dynamicevent : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e) { LinkButton button =new LinkButton(); button.Text ="switch"; button.Click +=new EventHandler(button_Click);this.View1.Controls.Add(button); }void button_Click(object sender, EventArgs e) {this.MultiView1.ActiveViewIndex = 1; }}

This code creates one LinkButton to switch from ActiveViewIndex=0 to 1 and it works just fine. However, on a larger scale, creating a hundred or more LinkButtons next to records that must be requested from a database each time the page handles a postback doesn't sound like a good idea to me. So, I moved by button creation code into an if(!IsPostBack) block:

protected void Page_Load(object sender, EventArgs e) {if (!this.IsPostBack) { LinkButton button =new LinkButton(); button.Text ="switch"; button.Click +=new EventHandler(button_Click);this.View1.Controls.Add(button); } }
The changes break the page. When I click the LinkButton, the updatepanel reloads the contents of the first view minus the linkbutton. The linkbutton is lost and its eventhandler with it. So, perhaps atlas requires that everything remain wired up perfectly up until after Page_Load() is called at least. I did some thinking and came up with some code that fixes the problem by using the cache to store the button to be rewired on the next postback. It appears that that is all the work I need to do to get my click handler to work. I think the benefits are significant enough although it is hard to see in this example: protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
LinkButton button =new LinkButton();
button.Text ="switch";
button.Click +=new EventHandler(button_Click);

this.View1.Controls.Add(button);
Cache.Insert("test", button);
}
else
{
((LinkButton)Cache["test"]).Click +=new EventHandler(button_Click);
this.FindControl(((LinkButton)Cache["test"]).Parent.UniqueID).Controls.Add(((LinkButton)Cache["test"]));
}
}

The code rewires the event handler during a postback. The Control.Parent .Controls.Add() does not work directly for the LinkButton in the cache but the FindControl() method works just fine. I believe that although they have the same name, the first parent of the LinkButton is not the same as the second one. I am new to ASP.NET v2 and Atlas but I do not remember coming across this problem in the past with .NET 1.1.

If anyone has a better solution, please let me know. At this moment I am facing writing some manager class to wire up all my eventhandlers on on each postback and I really would like a better way.


changed

this.FindControl(((LinkButton)Cache["test"]).Parent.UniqueID).Controls.Add(((LinkButton)Cache["test"]));
to
this.Controls.Add(((LinkButton)Cache["test"]));
and it works just fine. This means that it does not matter where the LinkButton is located, just that it is added back to the page.

Thanks a lot for the solution you posted. I have been facing the same problem and your solution worked for me. But, I wonder if there is some other solution to this issue. If I find any I will post it here.

Thanks again.


Yes, that's not specific to Atlas. Any control that's added dynamically to the control tree must be added back on every subsequent postback.

I came across another issue when I was working with this yesterday. What I saw was that after a few postbacks my dynamically added link buttons won't work in fact it threw an object required error. Reason, they were removed from the cache and hencethis.Controls.Add(((LinkButton)Cache["test"])); would not work.

So, I tried to check if the cache had the button in it and only then I would execute this statement else I would create new linkbuttons. But guess what, I got back to the same problem I started off with. The button would not fire the event.

In the solution we completely depend on the cache to make sure that the linkbuttons are wired to the respective events. What would happen when the buttons are removed from the cache for whatever reason, especially in a production environment?


Ok, I think I may have a solution for this...as bleroy indicated this is the default behavior with dynamically added controls (that you have to add them to the page on every postback). So, if you add the linkbuttons to the page on Page_Init instead of Page_Load, you will not have to worry about caching them in order to re-wire the controls with the events.

Let me know if this was helpful.


I'd like to respectfully point out that putting a control in the cache is a bad, bad, bad idea and you should never ever do it. One reason is that this maintains an in-memory reference to the instance of the control, hence to the corresponding instance of the page and thus to a huge object graph that should have been thrown away at the end of the request. There is no way this is not going to blow up whenever you get more than a few simultaneous requests.

You should only put data (that is, disconnected data) or output (i.e. strings) in cache...

Links dont work properly in a working Modal Popup

Is it possible to have client side <a href links inside an extender?

I've got a Modal Popup working. A webservice is invoke via javascript on the client. The webservice queries a database and returns html to the javascript which inserts the markup into the Modal Popup panel. The popup works well, displaying a title, a description and an image. It also displays a <a href link, however this link doesn't work as intended. It displays as a link but when clicked goes nowhere. I've tried it with and without target="_blank". The only way make it function is by right clicking on it and Opening in a new tab or in a new window. Any advice would be very welcome as I'm stuck and it's far from user friendly in it's current state.

Hi oscar,

Do you got some code that replicates the error?

Kind regards,
Wim


Hello,

What is resulting output of the link?

Thanks,

Louis


Thanks both for taking the time to help out. I tried logging in to reply, entered my password incorrectly once and my user account has now been locked out, despite it letting me reset my password.

I've now got this working.

The web service returns a string containing all of the markup to be displayed in the panel:

strdetails += "<a href="http://links.10026.com/?link="""onClick=""javascript:popUp('"
strdetails += ds.Tables(0).Rows(0)("livemaplink").ToString()
strdetails += "')"">Live Map</a>"

then with the rest of the javascript functions in the aspx page is this:

function popUp(URL)

{window.open(URL);}

I'd tried adding the popup function to the panel in the strdetails string and it didn't work but this does.

Thanks again.


Hi oscar Version 2Stick out tongue

Glad you got it to work!

Euhm, Even if none of our answer are actually solutions, I think you can still mark the thread as solved, somewhere on top, or mark your reply as answer. Because this thread is resolved ;)

Kind regards,
Wim


Will do, when my original account is unlocked that is!Big Smile

Cheers.


Will do, when my original account is unlocked that is!Big Smile

Cheers.

Monday, March 26, 2012

listbox in updatepannel takes to long

Hello, I have an updatePanel and inside of it i have textbox, listbox and div. And it all works perfecly if in the listbox i have to 100 rows. But in few cases i have arround 6000 rows. The problem occures when i select a row from the lisbox with 6000 rows and I'm tryning to put some message into the Div. It assignes the InnerHtml of the div and waits for about 1 minute with 100% processor activity and then it displays the div content. How can i shorten this time? Any sugestions?

Thanks

The UpdatePanel passes the ViewState for the whole page each time you do this, not to mention it sounds like 6000 records are being rebound. Remember the whole UpdatePanel needs to update... A better approach would to be use something like PageMethods to get the message (seehttp://encosia.com/index.php/2007/07/11/why-aspnet-ajax-updatepanels-are-dangerous) and then fill the DIV client-side.

-Damien


See the following thread and side threads for a long discussion of the problem and code that will cut the update time to milliseconds if your listbox is simple.

http://forums.asp.net/p/1065352/1540804.aspx

There are other ways of doing it as Damien suggested, but most of them involve the PageRequestManager (http://www.asp.net/AJAX/Documentation/Live/ClientReference/Sys.WebForms/PageRequestManagerClass/default.aspx) as the best solution.


http://forums.asp.net/t/1065004.aspx


Actualy I solved it with this link:

http://encosia.com/index.php/2007/07/13/easily-refresh-an-updatepanel-using-javascript/

ListSearchExtender - Inside HTML Table - Prompt position is above table

I've seen forum questions regarding this issue from several months ago.

Has a solution been found?

I am putting al dropdownlist inside an html table using a listsearchextender.

I have not modified the css, so it is using the sample that comes with the toolkit.

When I click on the dropdownlist, the search prompt displays above the table.

I also added several additional dropdownlists with extenders and they all put the search prompt above the table

Is there a work around to get the search prompt to display directly above the position of the dropdownlist regardless of what row it on in a table ?

Thanks.

Hi,

I tried what you described on the sample web site, but can't reproduce the issue. Here is the code I used:

<table>
<tr>
<td>
</td>
<td style="width: 103px">
aa</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td style="width: 103px">
bb</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td style="width: 103px">
<asp:DropDownList ID="DropDownList1" runat="server" Width="100px" /></td>
<td>
</td>
</tr>
</table>
<br />
<p>
<ajaxToolkit:ListSearchExtender ID="ListSearchExtender2" runat="server"
TargetControlID="DropDownList1" PromptCssClass="ListSearchExtenderPrompt">
</ajaxToolkit:ListSearchExtender>
</p>

ListSearchExtender prompt position

Would it be possible to add two new positions for the prompt: Left and Right? When using a DropdownList control inside of an HTML table the prompt cannot display correctly when positioned at the top of the control because it overwrites the list and it becomes unreadable. When inside of an HTML table it would be nice to be able to position the prompt either to the left or right of the control. Also, it would be good to have a prompt enable/disable feature because blanking the prompt text does not resolve the problem. I tried the workaround of setting the CSS class .list_search_method display:none; but that doesn't seem to work in some cases.

You could change the ListSearchExtender code easily to have it adapt to your scenario. Although, you shouldopen a work item to have us fix this.

You will need to add additional values to the ListSearchPromptPosition enum and modify the Behavior as well.

1 In the js file...
2
3 // Hook up a PopupBehavior to the promptDiv
4 this._popupBehavior = $create(AjaxControlToolkit.PopupBehavior, { parentElement : element }, {}, {},this._promptDiv);
5 if (this._promptPosition &&this._promptPosition == AjaxControlToolkit.ListSearchPromptPosition.Bottom) {
6 this._popupBehavior.set_positioningMode(AjaxControlToolkit.PositioningMode.BottomLeft);
7 }else if (this._promptPosition &&this._promptPosition == AjaxControlToolkit.ListSearchPromptPosition.Top) {
8 this._popupBehavior.set_positioningMode(AjaxControlToolkit.PositioningMode.TopLeft);
9 }else {
10 this._popupBehavior.set_x(getLeftOffset());// compute those offset values based on whether left or right was passed for the prompt position
11 this._popupBehavior.set_y(getTopOffset());// see popup control behavior on how it does that
12 }

Modify theenum...1516AjaxControlToolkit.ListSearchPromptPosition.prototype = {17 Top: 0,18 Bottom: 1,19 Left: 2,20 Right: 321}22AjaxControlToolkit.ListSearchPromptPosition.registerEnum('AjaxControlToolkit.ListSearchPromptPosition');In the cs file...26public enum ListSearchPromptPosition27 {28 Top = 0,29 Bottom=1,30 Left=2,31 Right=3,3233 }34


would you be able to advise your HTML that isn't working? Simply doing this:

 <table style="border: 2px solid black;"> <tr> <td><asp:ListBox ID="ListBox1" runat="server" Width="100px" /></td> </tr> </table> <ajaxToolkit:ListSearchExtender ID="ListSearchExtender1" runat="server" TargetControlID="ListBox1" PromptCssClass="ListSearchExtenderPrompt"> </ajaxToolkit:ListSearchExtender> works fine.


well, what it is overwriting is the top of the table and the border.

Basically to work around this, the behavior would have to create a span located above the textbox in its parent container.

I don't see that it overwrites the text of the list itself, though.


Thanks for the suggestion. I experimented a bit more based on your suggestion and found that by adding a row on top of the ListBox row allows the prompt to be displayed without clobbering anything around it. But if you need to place some text above the ListBox, then this workaround is not the best.

<table style="border: 2px solid black;">

<tr><td> </td></tr>


<tr>
<td><asp:ListBox ID="ListBox1" runat="server" Width="100px" /></td>
</tr>
</table>
<ajaxToolkit:ListSearchExtender ID="ListSearchExtender1" runat="server"
TargetControlID="ListBox1" PromptCssClass="ListSearchExtenderPrompt">
</ajaxToolkit:ListSearchExtender>


Thanks, I will open a work request as suggested. I had started to play with the source code last week and figured out the enum and prototype additions for Left and Right. I tried also to add code to check for ListSearchPromptPosition.Left and ListSearchPromptPosition.Right and was hoping that AjaxControlToolkit.PositioningMode.Left and AjaxControlToolkit.PositionMode.Right was already supported. I gave up at that point.

Here is what I tried to do:

3 // Hook up a PopupBehavior to the promptDiv
4 this._popupBehavior = $create(AjaxControlToolkit.PopupBehavior, { parentElement : element }, {}, {}, this._promptDiv);
5 if (this._promptPosition && this._promptPosition == AjaxControlToolkit.ListSearchPromptPosition.Bottom) {
6 this._popupBehavior.set_positioningMode(AjaxControlToolkit.PositioningMode.BottomLeft);
7 } else if (this._promptPosition && this._promptPosition == AjaxControlToolkit.ListSearchPromptPosition.Top) {
8 this._popupBehavior.set_positioningMode(AjaxControlToolkit.PositioningMode.TopLeft);
7 } else if (this._promptPosition && this._promptPosition == AjaxControlToolkit.ListSearchPromptPosition.Left) {
8 this._popupBehavior.set_positioningMode(AjaxControlToolkit.PositioningMode.Left);
7 } else if (this._promptPosition && this._promptPosition == AjaxControlToolkit.ListSearchPromptPosition.Right) {
8 this._popupBehavior.set_positioningMode(AjaxControlToolkit.PositioningMode.Right);
9 }

If I have time I will try to work out the code as suggested.

thanks!


Hi,

Was there ever a work item opened for this? Ability to position the prompt text more precisely would be helpful. Also, sometimes the dropdown opens down and sometimes it opens up. Then the prompt is covered up. Making the prompt position dynamic would be even better.

ListSearchExtender causing Sys.InvalidOperationException

Hello all,

I am having an issue with ListSearchExtender. I have the ListSearchExtender inside of an Panel, which is inside of an UpdatPanel. There is a CheckBox on the form, that when clicks, causes the Panel to become visible. When I select the CheckBox, the Panel shows up just fine an everything works. When I do anything that causes a postback after this is done, I get the following javascript error:

Sys.InvalidOperationException: Handler was not added through the Sys.UI.DomEvent.addHandler method.

I know the problem is coming from the ListSearchExtender because when I take it out, I do not get this error. Below is the UpdatePanel that contains the ListSearchExtender. Any help would be greatly appreciated.

Thanks,

Nick

<aspajax:UpdatePanel ID="upPharmacist" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="pnPharmacist" runat="server" Width="100%" Visible="false">
<table style="width: 100%;">
<tr>
<td align="left" colspan="2" bgcolor="#eeeeee">
Pharmacist Information</td>
</tr>
<tr>
<td class="wizardLeftColumn">
Address 1:</td>
<td class="wizardRightColumn">
<asp:TextBox ID="tbAddress1" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td class="wizardLeftColumn">
Address 2:</td>
<td class="wizardRightColumn">
<asp:TextBox ID="tbAddress2" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td class="wizardLeftColumn">
State:
</td>
<td class="wizardRightColumn">
<asp:DropDownList ID="ddState" runat="server">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="wizardLeftColumn">
Zip:
</td>
<td class="wizardRightColumn">
<asp:DropDownList ID="ddZip" runat="server">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="wizardLeftColumn">
City:</td>
<td class="wizardRightColumn">
<asp:TextBox ID="tbCity" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="wizardLeftColumn">
Phone 1:</td>
<td class="wizardRightColumn">
<asp:TextBox ID="tbPhone1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="wizardLeftColumn">
Phone 2:</td>
<td class="wizardRightColumn">
<asp:TextBox ID="tbPhone2" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="wizardLeftColumn">
Fax:</td>
<td class="wizardRightColumn">
<asp:TextBox ID="tbFax" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="wizardLeftColumn">
Provider Type:</td>
<td class="wizardRightColumn">
<asp:DropDownList ID="ddProviderTypes" runat="server" DataSourceID="odsProviderTypes"
DataTextField="TypeDescription" DataValueField="TypeCode">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="wizardLeftColumn">
Medicaid Provider Id:</td>
<td class="wizardRightColumn">
<asp:TextBox ID="tbMedicaidId" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="wizardLeftColumn">
County:</td>
<td class="wizardRightColumn">
<asp:TextBox ID="tbCounty" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="wizardLeftColumn">
DUR Region:</td>
<td class="wizardRightColumn">
<asp:TextBox ID="tbDURRegion" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="wizardLeftColumn">
License Number:</td>
<td class="wizardRightColumn">
<asp:TextBox ID="tbLicenseNumber" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="wizardLeftColumn">
License State:</td>
<td class="wizardRightColumn">
<asp:DropDownList ID="ddLicenseState" runat="server">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="wizardLeftColumn">
NPI:</td>
<td class="wizardRightColumn">
<asp:TextBox ID="tbNPI" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="wizardLeftColumn">
EIN/SSN:</td>
<td class="wizardRightColumn">
<asp:TextBox ID="tbSSN" runat="server"></asp:TextBox>
</td>
</tr>
</table>
</asp:Panel>
<ajaxToolkit:CascadingDropDown ID="cddState" runat="server" TargetControlID="ddState"
Category="State" PromptText="Please select..." LoadingText="[Loading codes...]"
ServiceMethod="GetStates" ServicePath="Services/AjaxAccessService.asmx">
</ajaxToolkit:CascadingDropDown>
<ajaxToolkit:CascadingDropDown ID="cddZip" runat="server" TargetControlID="ddZip"
Category="Zip" PromptText="Please select..." LoadingText="[Loading codes...]"
ServiceMethod="GetZipCodes" ServicePath="Services/AjaxAccessService.asmx" ParentControlID="ddState">
</ajaxToolkit:CascadingDropDown>
<ajaxToolkit:ListSearchExtender ID="lseZip" runat="server" TargetControlID="ddZip"
PromptPosition="Bottom" BehaviorID="lseZip">
</ajaxToolkit:ListSearchExtender>
<ajaxToolkit:CascadingDropDown ID="ccdLicenseState" runat="server" TargetControlID="ddLicenseState"
Category="State" PromptText="Please select..." LoadingText="[Loading codes...]"
ServiceMethod="GetStates" ServicePath="Services/AjaxAccessService.asmx">
</ajaxToolkit:CascadingDropDown>
</ContentTemplate>
</aspajax:UpdatePanel>

Has no one else run into this problem? I was really hoping to use the ListSearchExtender in this manner.

Thanks,

Nick

Saturday, March 24, 2012

Literal Control Update Panel IE6

I have two buttons and a literal control placed inside an update panel which is sitting inside of a Drag Panel which is inside of some animation to display the initial panel. In IE7, everything works properly - when you click a button to refresh the image being drawn in the literal control, the button's text in changed to "Processing..." and then, when the response is obtained, the image is refreshed and the button's text is reverted back to its original state.

In IE7, however, the button works fine but the image never refreshs - even though I am re-writing the Literal upon postback. It is almost as if IE is caching the image. Does anybody know how to correct this issue?

Thanks!

In IE7 there is the animation disable by default, you can enable that in options.

Literal nested in UpdatePanel error: "Object reference not set to an instance of an object

I am trying to set the content of a literal which is nested inside an UpdatePanel. But when I try to reference the Literal control, I get this message: "Object reference not set to an instance of an object." This despite the fact that the name shows in Intellisense. Actually, not entirely true. It sometimes isn't showing in Intellisense, for reasons I can't fathom. But I'm not getting a compilation error, so I assume it does recognise the name, but for some reason the object is null. Here's the code:

 <asp:UpdatePanel runat="server" ID="UpdatePanel1" EnableViewState ="true" Visible="true" RenderMode="Block" UpdateMode="Conditional"> <asp:ContentTemplate> <div style="width:350px; height:400px" class="newscontent"> <asp:Literal runat="server" ID="litContent"></asp:Literal> </div> </asp:ContentTemplate> </asp:UpdatePanel>

C#:

protected void Refresh(Object Sender, RepeaterCommandEventArgs e) {if (e.CommandName=="GetContent") {int id = Convert.ToInt32((e.CommandArgument)); ObjectModel.News item =new ObjectModel.News(id); litContent.Text = item.Content; litContent.Text += DisplayDocuments(id); UpdatePanel1.Update(); } }
The Refresh function is triggered by the user clicking on a LinkButton in a repeater, but this is irrelevant to the problem, since I get the same error message if I put a simple line of code in the page load function to set the text property on the the literal.

just yesterday got same problem with accordion control and textbox

spend about 3 hours here how it goes :UpdatePanel1 onpage load or on page init try this code

///////////////////////////////////////////////////////////////////////////

Literal litContent=newLiteral();

litContent= UpdatePanel1.FindControl ("litContent") asLiteral;

////////////////////////////////////////////////////


Sol90046:

just yesterday got same problem with accordion control and textbox

spend about 3 hours here how it goes :UpdatePanel1 onpage load or on page init try this code

///////////////////////////////////////////////////////////////////////////

Literal litContent=newLiteral();

litContent= UpdatePanel1.FindControl ("litContent") asLiteral;

////////////////////////////////////////////////////

Thank you! This worked as far as eliminating my error message went. But even though the code now appears to be doing what it is told, i.e., I can step through it in debug mode and the text property of the Literal is being set to the correct content, the update panel is not displaying the results. It also appears to be doing a full page refresh rather than a partial one. I do have a scriptmanager on the page with EnablePartialRendering set to true.

Load content on demand or in portions

Hi,

I have large chunks of text (400-500Kb) that are loaded inside update panel when user clicks on a tree node with the book name. It works fine and all. The only thing is that the text is first downloaded to client and then shown - the user will have to wait for the whole 400Kb of text to download. Is there a way to show the first 5-10Kb of text once it has reached the client and keep loading the reast while user is reading?

And one more question - is this ok that Page_Load() event is fired every time UpdatePanel is updated?

Hi abolotnov,

To start with your last question it is normal that the page_load event get fired when you are doing a partial update. The trick is within the rendering of the HTML, so thats correct. What kind of control is inside your UpdatePanel (treeview?) You can use a updateprogress control to make clear to the user that the page is still updating. Can you past some code here so we can analyze your code. Thanks

Regards,


yeah, I know I can use UpdateProgress control to tell the user that the page is still updating... this is not I really want though -

say I have this UpdatePanel with DIV inside of it and need the text in DIV to be updated. The text is 400K - quite a lot for people with slow internet connection (dialup for example). I want them to be able to start reading the text before it's downloaded in whole. Say, if their connection speed is 4K/sec, they will be able to start reading in 1 second - 4K of text gives them enough to read before the rest is downloaded - another 4k will come next second etc.

What I have now is when the update starts use sees this message "content for reading pane is being updated, please wait" untill the whole portion of text is downloaded and then rendered. For people on slow internet connections it takes quite a while 400/4 secs.


Don't ask me why I can't split the text into smaller portions and allow users to page through the text - I will if there is no way to sort out what I want.

Thanks for any comments you may have on this.