Showing posts with label server. Show all posts
Showing posts with label server. Show all posts

Wednesday, March 28, 2012

Linebreak appears after update panel submits

I wrote a control that would allow a user to click on a label, and then edit it the value, and send back the new value to the server via an update panel.

However, the first time the value is sent to the server, a line break appears right above the text box, i dont think this is a css error, i can't seem to figure out what is causing it by examining the DOM. This only appears in IE, not Firefox, Any ideas?

Here's the mark up for the Control

<%@dotnet.itags.org. Control Language="VB" AutoEventWireup="false" CodeFile="QuickEditLabel.ascx.vb" Inherits="QuickEditLabel" %><script type="text/javascript"> function<%=Me.hidCurrentFileId.ClientID%>updateNumber(param) { var hiddenField = document.getElementById("<%=hidCurrentFileId.ClientID%>"); hiddenField.value = param; __doPostBack('<%=hidCurrentFileId.ClientID%>',''); } function QuickEditSwap(hideMe, showMe) { showMe.style.display = 'none'; hideMe.style.display = 'inline'; }</script><asp:HiddenField ID="hidCurrentFileId" runat="server" Value="" /><asp:UpdatePanel ID="updPanel" UpdateMode="Conditional" runat="server"> <Triggers> <asp:AsyncPostBackTrigger ControlID="hidCurrentFileId" EventName="ValueChanged" /> </Triggers> <ContentTemplate>   <asp:Label ID="Label1" runat="server" CssClass="QuickEditText" ToolTip="Click to Edit"></asp:Label> <asp:TextBox ID="TextBox1" runat="server" CssClass="QuickEditTextBox" Width="93px"></asp:TextBox> </ContentTemplate></asp:UpdatePanel>

Here's the Code behind for the control

PartialClass QuickEditLabelInherits System.Web.UI.UserControlPrivate myTextAs String Public Property Text()Get Return myTextEnd Get Set(ByVal value) myText = valueEnd Set End Property Protected Sub Page_Load(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Me.LoadIf Not IsPostBackThen Me.Text ="33"Else Me.Text =Me.TextBox1.TextEnd If Me.TextBox1.Attributes.Add("onchange",Me.hidCurrentFileId.ClientID +"updateNumber(getElementById('" + Me.TextBox1.ClientID + "').value)") Me.Label1.Attributes.Add("onclick", "QuickEditSwap(getElementById('" + Me.TextBox1.ClientID + "'), getElementById('" + Me.Label1.ClientID + "'))")End Sub Protected Sub Page_PreRender(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Me.PreRenderMe.Label1.Text =Me.TextMe.TextBox1.Text =Me.TextEnd SubEnd Class

Here's the css i'm using for the control

 .QuickEditText {font-family: Verdana;} .QuickEditText:hover {text-decoration: underline; font-family: Verdana; cursor: pointer} .QuickEditTextBox {display: none; font-family:Verdana;}

Thanks in advance for any suggestions,

This is happening because of the default setting of the UpdatePanel's RenderMode property - which will render its contents into a <div> the first time. Try changing it to "Inline" so that it will instead render a <span> element.

Saturday, March 24, 2012

Load data into server controls

I am using Atlas to get a list of Serial numbers from a database as the user types in part of the serial number. It works great. Now I want to be able to populate other textbox controls on the form as the user types in that serial number. Is this possible using Atlas? I know I could put a button next to the serial number so when they get the serial number they are looking for they could submit the form and I could do a "SELECT * FROM inv_assets WHERE sserial_num = txtSerialNum.Text, but this would cause the page to refresh and I would really like to somehow populate the rest of the form as the user types in the serial number.

perhaps using a placeholder into an updatepanel.

load server page like frame

i have a page. this page loads to client. how can i load to this page (in selected area) another page from server, like in iframe but using ajax?

Hi,

Thank you for your post!

You can still use Iframe,then change the src of the Iframe to the page you want to load.

If you really want use Ajax, place a Iframe in an updatepanel.

If you have further questions,let me know!

Best Regards,

Wednesday, March 21, 2012

LoadControl and UpdatePanel

hi all,

I am having problems with server controls placed inside an UpdatePanel. they are placed in an acsx (web control) and I am loading them (following instructions encoded in an XML) using LoadControl. but, the inside controls are null.

I am quite sure I've got the page lifecycle messed up somehow. here's a detailed description of what I am doing:

I have got a web control named Canvas (as it is supposed to hold other controls, as well as other Canvases). it has got an UpdatePanel with a PlaceHolder in the ContentTemplate.

I have embedded one Canvas (obviously called Root) in my aspx page, which has the ScriptManager in it.

in the Page_Load event of the original aspx page (I tried Page_PreInit as well, doesn't work) I am dynamically creating other Canvases (by LoadControl) and adding it in my PlaceHolder. I have a method that takes an XML and I am calling that method. it works fine for the root.

however, after I have loaded my control, I call the XML accepting method (with a child XML node) of the newly created control. this is where it gets stuck with a null exception. so it's right after the LoadControl call.

I hope I haven't made a trivial mistake. I removed my UpdatePanel and it works just fine. so it can't be terribly wrong! I am using the January CTP.

cheers.

help! somebody? anybody?

I had the same issue and I just resolved it. You need to add an ID to your control... then it will persist on postbacks. That's all you do (and always create the control in the page_load event). Here's my code and it works like a champ and I'm using MS's AJAX panels as well.

i'm placing a unique control on the page based on the tab they are on but you could just add a single control here as well. Don't worry about the LoadData, those are just methods that load my data into the controls.

Good luck!

protected void Page_Load(object sender, EventArgs e) { LoadPageViewData(radCategoryTabStrip.SelectedIndex); }
private void LoadPageViewData(int index) {//-- clear out the controls pageDynamic.Controls.Clear();string guid = String.Empty;if (lblDetailData.Attributes["GUID"] !=null) { guid = lblDetailData.Attributes["GUID"].ToString(); }switch (index) {case 0://-- create the control CustomControls_Group_Edit oCtrlGroupItemEdit = (CustomControls_Group_Edit)LoadControl("~/CustomControls/Group/Edit.ascx");//new CustomControls_Group_Edit(); //-- wire up the event handler, this way we'll get notified when the control //-- save's it's data and we can update the tree on this page. oCtrlGroupItemEdit.GroupItemSaved +=new EventHandler(itemSaved);//-- give it an id, that way the page_load event will know to rebind it //-- to the same instance on postbacks and persist the data //-- (read an article about it and it works) oCtrlGroupItemEdit.ID ="GroupEdit1";//-- add the control to the page before we invoke the first method multiPage.PageViews[0].Controls.Add(oCtrlGroupItemEdit);//-- load the data oCtrlGroupItemEdit.LoadData(guid);break;case 1://-- not doing any custom events for this one, so just load the control CustomControls_Groupings_ProductList oCtrlProductList = (CustomControls_Groupings_ProductList)LoadControl("~/CustomControls/Groupings/ProductList.ascx");//-- add the control the page before we invoke the first method oCtrlProductList.ID ="ProductList1"; pageDynamic.Controls.Add(oCtrlProductList);//-- this must be called after it's added to the control collection (not before or it will fail) oCtrlProductList.LoadData(guid);break;case 2:break;case 3:break; }//-- make sure this control is selected pageDynamic.Selected =true;//-- either works: multiPage.PageViews[0].Selected = true; //-- update the ajax panel updatePanelCategoryInfo.Update(); }

loading a page is taking too long

Hello.. On a page in a AjaxEnabledWebApplication I have 3 server controls (asp:ScriptManager, asp:Timer, asp:UpdatePanel) and some HTML controls(some inputs). Sometimes, when IIS loads the page, the loading works fine(max 1 second)... but sometimes it`s taking a couple of minutes. Everything is on localhost and I don`t have any database connections.

Can someone help me?

thanks

One more specification... This happens only I run the application from Visual Studio 2005(F5). If I run the application from a browser, everything works great.

Thanks


ASP.NET AJAX at the first time when you run your project in degug(F5) may take a few extra time becose the deguge mode is true.when you publish your website specifydebug="false" in web.config file .or try debug = false ,you will see it faster.

Regards.


I think I`ve tricked him... I set the IIS as the development server(from project proprietes... not the one from Visual Studio..) and now works great...

Loading scripts

Ajax controls always load scripts throw ScriptResource.axd. So we hava many requests to the server. I think if there is a possibility to load these scripts together it will be faster page loading. What do you think about it?

Hi,

did you set your application in debug mode? If so then the debug versions of the javascripts will be loaded each time and remember these debug versions are also bigger then their release versions. You can check your settings in the web.config:<compilation> element.

Grz, Kris.


my problem is not in the big debug files. in the release mode I have the same problem: too much requests to the server. I'm interesting of how can I load ajas scripts not partialy.


Solution is simple. In The new ToolKit release we have new feature "ScriptCombining". It is real working. Tomorrow I'll test it in the real project.

But maybe anybody know ho to do it in with old version of toolkit?


Does anybody use new toolkit? I have less requests to the server but page size is bigger with new options.


Hi,

I compared the results, but there is no significant difference in size.