if (Parent.Page.ClientScript.IsClientScriptBlockRegistered(AddressScriptName))
Parent.Page.ClientScript.RegisterClientScriptBlock(
this.GetType(), AddressScriptName, MakeScript());
m_rwAddressLookups.ClientCallBackFunction =
"CallBackFromAddressFunction" + AddressScriptName;
m_btnAdressLookup.Attributes.Add(
"onclick", "return ShowAddressLookupDialog" + AddressScriptName + "();");
private string AddressScriptName{
get { return "AddressScript" + this.ClientID; }
}
private string MakeScript()
{
return @"<script type='text/javascript'>
function ShowAddressLookupDialog"
+ AddressScriptName + @"()
{
var manager = $find('<%=m_rwmAddressLookups.ClientID %>');
manager.open(null, 'm_rwAddressLookups');
return false;
}
function CallBackFromAddressFunction"
+ AddressScriptName + @"(radWindow, returnValue)
{
var oArea = document.getElementById('<%=m_tbAddressId.ClientID %>');
if (returnValue)
{
oArea.innerText = returnValue.toString();
oArea.onchange();
}
}
</script>"
;
}
WHen I click the address lookup button the onclick event complains Object Expected on bolded function:
<
input type="submit" name="ctl00$ContentPlaceHolder1$m_contactAddressEdit$m_btnAdressLookup" value="Lookup Address" onclick="return ShowAddressLookupDialogAddressScriptctl00_ContentPlaceHolder1_m_contactAddressEdit();WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$ContentPlaceHolder1$m_contactAddressEdit$m_btnAdressLookup", "", true, "", "", false, false))" id="ctl00_ContentPlaceHolder1_m_contactAddressEdit_m_btnAdressLookup" class="FormButton" />
Appears that it does not find the client id qualified script function.
Any ideas?
| <form runat="server" id="form1"> |
| <telerik:RadScriptManager ID="RadScriptManager1" runat="server"> |
| </telerik:RadScriptManager> |
| <telerik:RadTextBox ID="RadTextBox1" runat="server" ShowButton="false" |
| Width="125px"></telerik:RadTextBox> |
| </form> |
Protected Sub AccountDetails_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles AccountDetails.NeedDataSource- Only some of the fields within the object are displayed in the RadGrid (pk is not displayed); several fields are not primative types (two fields are also collections).
accts = af.GetAccounts(TreeNav.SelectedValue) 'where af.GetAccounts returns a collection of accounts
AccountDetails.DataSource = accts
End Sub
I'm having a problem figuring out the correct way to populate an edit form with data when using a master/detail hierarchy.
The problem I'm having is when I show the edit form for a detail item in one hierarchy group the data in any visible edit form in the other hierarchy groups no longer has data so the edit form is empty. I'm using the edit form to display additional, static, information about the detail item.
The way I currently have it setup is to use the ItemDataBound event to check if the item is in edit mode and if it's a GridEditFormItem. From there I can get the DataItem from the item to populate labels in the edit form template. This works fine when showing the edit form for any of the detail rows in the current hierarchy group. However, checking e.Item.IsInEditMode only catches the items in the hierarchy group the expanded item is in. This means the other previously expanded hierarchy group detail rows never get repopulated with data so their form's are blank and introduces my problem.
I tried to update my code to use the ItemCreated event but for the items not in the current hierarchy group both the e.Item.DataItem and the edit form's ParentItem.DataItem are null.
Anyone have any suggestions or other questions that might help me track down the correct way to do this?
User does not receive an error? Has anybody coded around this? Or better
yet, anyway to make the day selected on the calendar the default day
selected.
Thanks in advance
<telerik:RadAjaxManager id="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="RadGridPages">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGridPages" LoadingPanelID="RadAjaxLoadingPanel1"/>
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Height="75px" Width="75px" Transparency="50">
<img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>' style="border:0;" />
</telerik:RadAjaxLoadingPanel>
<telerik:RadGrid id="RadGridPages" CssClass="RadGrid" EnableTheming="False" EnableEmbeddedBaseStylesheet="False" AllowSorting="True" AllowMultiRowSelection="true"
Skin="" runat="server" Width="100%" AllowPaging="True" AutoGenerateColumns="False" PageSize="5" >
<alternatingitemstyle cssclass="RadGridItem" />
<ItemStyle CssClass="RadGridItem" ></ItemStyle>
<HeaderStyle CssClass="RadGridHeader"></HeaderStyle>
<PagerStyle Mode="Slider" alwaysvisible="True" CssClass="RadGridPager" Visible="true" EnableSEOPaging="True" ></PagerStyle>
<ClientSettings EnablePostBackOnRowClick="false">
<Selecting AllowRowSelect="true" />
</ClientSettings>
<MasterTableView CommandItemDisplay="Top" AutoGenerateColumns="False" Width="100%">
<CommandItemTemplate>
<div style="padding:10px 0px;" class="newtd">
<asp:LinkButton ID="LinkButton1" OnClientClick="javascript:return confirm('Delete the Webpage(s)?')"
runat="server" CommandName="DeleteSelected" CausesValidation="false" ><img style="border:0px;vertical-align:middle;" alt="" src="../Images/icons/Delet.gif" /> Delete the Webpage(s)</asp:LinkButton>
<asp:LinkButton ID="LinkButton4" runat="server" CommandName="RebindGrid"><img style="border:0px;vertical-align:middle;" alt="" src="../Images/icons/Refresh.gif" /> Refresh </asp:LinkButton>
</div>
</CommandItemTemplate>
<Columns>
<telerik:GridTemplateColumn UniqueName="SrlNo" AllowFiltering="False" ItemStyle-HorizontalAlign="Left" ItemStyle-Width="2%" >
<ItemTemplate >
<asp:Label ID="lblSrlNo" runat="server" />
<asp:Label ID="lblSelectedNew" Text='<%# Container.DataItem("WebSite") & "_" & Container.DataItem("PageName") %>' runat="server" Visible="false"></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridClientSelectColumn HeaderStyle-Width="3%" />
<telerik:GridBoundColumn DataField="WebSite" UniqueName="WebSite" ItemStyle-HorizontalAlign="Left" HeaderText="Website" ShowSortIcon="false" ></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="PageName" UniqueName="PageName" ItemStyle-HorizontalAlign="Left" HeaderText="Webpage" ShowSortIcon="false" ></telerik:GridBoundColumn>
<%
-- <telerik:GridBoundColumn DataField="OriginalLocation" UniqueName="OriginalLocation" HeaderText="Original Location" ItemStyle-HorizontalAlign="Left" ShowSortIcon="false"></telerik:GridBoundColumn>
--
%>
<telerik:GridBoundColumn DataField="DeletedDate" UniqueName="DeletedDate" HeaderText="Deleted Date" ItemStyle-HorizontalAlign="Left" ShowSortIcon="false"></telerik:GridBoundColumn>
<telerik:GridTemplateColumn UniqueName="Restore" HeaderText="Restore" AllowFiltering="False">
<ItemTemplate>
<asp:LinkButton ID="LinkButton2" runat="server" Text="Restore" CommandName="PageName" CommandArgument='<%# Container.DataItem("WebSite") & "_" & Container.DataItem("PageName") %>' ></asp:LinkButton>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
<ExpandCollapseColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
<RowIndicatorColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
</MasterTableView>
<FilterMenu EnableTheming="True" Skin="WebBlue" enableembeddedbasestylesheet="False">
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
</FilterMenu>
</telerik:RadGrid>
and my Server side code...is
Imports
Telerik.Web.UI
Partial
Class Clients_ManageRecycled
Inherits System.Web.UI.Page
Dim oDb As New CMSDatabase
Dim SqlQry As String = ""
Dim ClientName As String = ""
Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
Dim UserTheme As MyThemes = Val(Session("@Theme"))
Me.Theme = UserTheme.ToString
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Ajax.Utility.RegisterTypeForAjax(
Me.GetType)
ClientName = oDb.ExecuteScaler(
"Select DbName from clients where clientid =" & Request.QueryString("CID"))
' LinkButton1.Attributes.Add("Onclick", "javascript:return(fn_ValidateDelUsers(this.form));")
Session(
"AppSortOrder") = "Asc"
Session(
"AppSortName") = "Name"
End Sub
Protected Sub txtSearch_TextChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim txt As TextBox = TryCast(DirectCast(sender, TextBox), TextBox)
Dim list As RadComboBox = DirectCast(((txt.NamingContainer).FindControl("rcbFieldName")), RadComboBox)
Dim [option] As String
If list.SelectedValue = "RestorePath" Then
[option] =
" = "
Else
[option] =
" LIKE "
End If
Dim filterExpression As String
If [option] = " = " Then
filterExpression =
"(" + list.SelectedValue + [option] + txt.Text + ")"
Else
filterExpression =
"(" + list.SelectedValue + [option] + "'" + txt.Text + "%'" + ")"
End If
RadGridPages.MasterTableView.FilterExpression = filterExpression
RadGridPages.MasterTableView.Rebind()
End Sub
Protected Sub RadGridPages_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGridPages.NeedDataSource
Try
Dim DT As New DataTable
Dim MysitePath As String = Replace(ConfigurationManager.AppSettings("MapPath"), "/", "\")
MysitePath = Mid(MysitePath, 1, InStrRev(Mid(MysitePath, 1, Len(MysitePath) - 1),
"\"))
MysitePath = MysitePath &
"_Recycled\" & ClientName & "\"
hidRecycledPath.Value = MysitePath
Dim Dir As New DirectoryInfo(MysitePath)
DT.Columns.Add(
New Data.DataColumn("PageName"))
DT.Columns.Add(
New Data.DataColumn("OriginalLocation"))
DT.Columns.Add(
New Data.DataColumn("DeletedDate"))
DT.Columns.Add(
New Data.DataColumn("WebSite"))
Dim DR As Data.DataRow
For Each Website As DirectoryInfo In Dir.GetDirectories
For Each WebPage As FileInfo In Website.GetFiles("*.aspx")
'Response.Write(Website.Name & "\" & WebPage.Name & "<br>")
DR = DT.NewRow()
DR.Item(
"PageName") = Replace(WebPage.Name, WebPage.Extension, "")
DR.Item(
"OriginalLocation") = Website.Name & "_Stage"
DR.Item(
"DeletedDate") = WebPage.LastWriteTime
DR.Item(
"WebSite") = Website.Name
DT.Rows.Add(DR)
Next
Next
DT.AcceptChanges()
RadGridPages.Visible =
True
RadGridPages.DataSource = DT
Catch ex As Exception
RadGridPages.Visible =
False
lblMsg.Text =
"No File Found"
End Try
End Sub
Protected Sub RadGridPages_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGridPages.ItemDataBound
If e.Item.ItemType = GridItemType.AlternatingItem Or e.Item.ItemType = Telerik.Web.UI.GridItemType.Item Then
'e.Item.Cells(3).Text = e.Item.DataSetIndex + 1
Dim lbl As Label
lbl =
CType(e.Item.FindControl("lblSrlNo"), Label)
lbl.Text = e.Item.ItemIndex + 1
Dim lblchk As Label
lblchk =
CType(e.Item.FindControl("lblSelectedNew"), Label)
End If
End Sub
Protected Sub RadGridPages_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGridPages.ItemCommand
If e.CommandName = "PageName" Then
Dim sql As String = ""
Dim Odt As New DataTable
sql =
"select * from " & ClientName & ".dbo.Recycled where WebPageName like '" & e.CommandArgument.ToString.Split("_")(1) & "'"
'Response.Write(sql)
If oDb.IsExist(sql) Then
Odt = oDb.GetDataTable(sql)
Dim Tree As New ManageTree
Dim StructID As Decimal
For Each dr As DataRow In Odt.Rows
'Response.Write(dr.Item("ParentPath"))
Dim fileOldAspx As New FileInfo(hidRecycledPath.Value & e.CommandArgument.ToString.Split("_")(0) & "\" & e.CommandArgument.ToString.Split("_")(1) & ".aspx")
Dim fileOldAspxVb As New FileInfo(hidRecycledPath.Value & e.CommandArgument.ToString.Split("_")(0) & "\" & e.CommandArgument.ToString.Split("_")(1) & ".aspx.vb")
If File.Exists(hidRecycledPath.Value & e.CommandArgument.ToString.Split("_")(0) & "\" & e.CommandArgument.ToString.Split("_")(1) & ".aspx") Then
fileOldAspx.MoveTo(dr.Item(
"ParentPath"))
fileOldAspxVb.MoveTo(dr.Item(
"ParentPath") & ".vb")
End If
StructID &=
"," & Tree.CreateWebPage(e.CommandArgument.ToString.Split("_")(1), dr.Item("ParentID"), Request.QueryString("CID"), e.CommandArgument.ToString.Split("_")(0))
sql =
"delete from " & ClientName & ".dbo.Recycled where WebPageName like '" & e.CommandArgument.ToString.Split("_")(1) & "'"
oDb.ExecuteNonQuery(sql)
Next
Dim MyLoadscript As String = "parent.fraMnu.AddNode(""" & ClientName & """, """ & StructID & """);"
Page.ClientScript.RegisterStartupScript(
Me.GetType, "MyLoadscript", MyLoadscript, True)
'RadGridPages.Rebind()
End If
End If
End Sub
Protected Sub RadGridPages_DeleteCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGridPages.DeleteCommand
Dim Wbpage As Label
Dim Sql As String
Dim i As Integer
Wbpage =
CType(e.Item.FindControl("lblSelectedNew"), Label)
File.Delete(hidRecycledPath.Value & Wbpage.Text.Split(
"_")(0) & "\" & Wbpage.Text.Split("_")(1) & ".aspx")
File.Delete(hidRecycledPath.Value & Wbpage.Text.Split(
"_")(0) & "\" & Wbpage.Text.Split("_")(1) & ".aspx.vb")
Sql =
"select structureid from " & ClientName & ".dbo.Recycled where WebPageName like '" & Wbpage.Text.Split("_")(1) & "'"
Dim MyLoadscript As String = "parent.fraMnu.AddNode(""" & ClientName & """, """ & oDb.ExecuteScaler(Sql) & """);"
Page.ClientScript.RegisterStartupScript(
Me.GetType, "MyLoadscript", MyLoadscript, True)
Sql =
"delete from " & ClientName & ".dbo.Recycled where WebPageName like '" & Wbpage.Text.Split("_")(1) & "'"
oDb.ExecuteNonQuery(Sql)
'RadGridPages.Rebind()
End Sub
Protected Sub RadGridPages_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGridPages.ItemCreated
If TypeOf e.Item Is GridPagerItem AndAlso TryCast(sender, RadGrid).PagerStyle.Mode = GridPagerMode.Slider Then
TryCast(TryCast(e.Item, GridPagerItem).Controls(0).Controls(1), RadSlider).EnableEmbeddedBaseStylesheet = True
TryCast(TryCast(e.Item, GridPagerItem).Controls(0).Controls(1), RadSlider).EnableEmbeddedSkins = True
TryCast(TryCast(e.Item, GridPagerItem).Controls(0).Controls(1), RadSlider).Skin = "WebBlue"
End If
End Sub
End
Class
One more thing this works fine if I change the page navigation mode to other mode other than slider.
<telerik:RadAjaxLoadingPanel ID="UCCRadAjaxLoadingPanel" runat="server" Height="75px" Width="75px" Transparency="50" MinDisplayTime="500">
<img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>' style="border:0;" />
</telerik:RadAjaxLoadingPanel>
<telerik:RadAjaxManager runat="server" ID="UCCIndexingRadAjaxManager" OnAjaxRequest="UCCIndexingRadAjaxManager_AjaxRequest">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="UCCIndexingRadAjaxManager">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="ucUCCIndexingFilingControlsParent" LoadingPanelID="UCCRadAjaxLoadingPanel" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
- Lastly, here is the javascript function that calls ajaxrequest. This does fire the event and the code behind runs, but I never see the loading panel.
- As you can see with the commented out code, I have even tried to show the loading panel explicitly with code, by finding it and calling the show method. No luck there either.
function saveFiling()
{
//alert("You hit ctrl-s");
//currentLoadingPanel = $find("ctl00_ContentPlaceHolder_UCCRadAjaxLoadingPanel");
//currentUpdatedControl = "ctl00_ContentPlaceHolder_ucUCCIndexingFilingControlsParent_ucFilingDetails";
//currentLoadingPanel.show(currentUpdatedControl);
$find("<%=UCCIndexingRadAjaxManager.ClientID%>").ajaxRequest("SaveLienFiling");
}
//disable ajax in case of uploading files
if(args.EventTarget == "<%=LinkButton_Send.UniqueID%>")
{
args.EnableAjax =
false;
}