Showing posts with label tabs. Show all posts
Showing posts with label tabs. Show all posts

Saturday, March 24, 2012

Triggering partial update on text box losing focus

Hi,

I have a form on which I want a user to be able to enter a post code and, when the user tabs out of the field, triggers the population of a drop down list which contains the suburbs the postcode relates to, so the user can then select the suburb.

I have the drop down list in an Update Panel with partial rendering turned on but I can't figure out how to trigger it being refreshed when the control loses focus. I think I need to link it to the OnBlur event using javascript but I'm stuck at that point. Any ideas appreciated...

Thanks,

SimonOK, it was me being dippy. I didn't need to get clever and start hooking client side events, I just needed to set the Render property to "Always" and it fires whenever the text box loses focus.

S

Wednesday, March 21, 2012

trouble with dynamic tabs

Hi I am having two issues with trying to create dynamic tabs with the AjaxControlToolkit Tabs Control. First when I click the button1 to create the tab it creates 2 tabs and if I hit the button again I get the error "Specified argument was out of the range of valid values"

My aspx is

<%@dotnet.itags.org. Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" EnableEventValidation="false" %
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<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="ScriptManager1" runat="server" />
<script type="text/javascript">

</script>
<div>
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Add Tab" /><br />
<br />
<br />
<br />
<ajaxToolkit:tabcontainer id="TabContainer1" runat="server" activetabindex="0">
</ajaxToolkit:tabcontainer></div>
</form>
</body>
</html>


My vb code is:

PartialClass _DefaultInherits System.Web.UI.PageProtected Sub Button1_Click(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Button1.ClickDim tabAs AjaxControlToolkit.TabPanel =New AjaxControlToolkit.TabPanel()Dim frame1As System.Web.UI.HtmlControls.HtmlGenericControl =New System.Web.UI.HtmlControls.HtmlGenericControl("iframe") frame1.Attributes("src") ="http://search.msn.com" frame1.Attributes("frameborder") ="0" frame1.Attributes("width") ="800" frame1.Attributes("height") ="600" frame1.Attributes("scrolling") ="auto" tab.Controls.Add(frame1) tab.Width ="800" tab.Height ="600" tab.HeaderText ="Tab " TabContainer1.Tabs.Add(tab) TabContainer1.ActiveTab = tabEnd SubEnd Class
Any help would be greatly appreciated.

Hi,

This is a common problem when working with dynamic controls.

The problem is that dynamic controls don't exist on the second request before the Button1_Click method fires. You need to recreate it in Page_Init rather than Button_Click.

Please refer to this documentation for more information:

1. Why do I have to recreate dynamic controls every time? /Why dynamic controls are disappeared on PostBack?

Whenever a request comes, a new instance of the page that isbeing requested is created to serve the request even it's a PostBack. Allcontrols on the page are reinitialized, and there state can be restored fromthe ViewState in a later phase.

The dynamic controls have to be recreated again and added tothe control hierarchy. Otherwise, they won't exist in the page.

Please be careful with when to create dynamic controls. Inorder to keep their state, they have to be created before the LoadViewStatephase. Page_Init as well as Page_Load methods are options available.

For more information about this topic, please refer to thisarticle:

Creating Dynamic Data Entry User Interfaces[http://msdn2.microsoft.com/en-us/library/aa479330.aspx ]

Hope this helps.