<
telerik:RadToolBar
ID
=
"barActions"
runat
=
"server"
onbuttonclick
=
"barActions_ButtonClick"
Width
=
"100%"
>
<
Items
>
<
telerik:RadToolBarButton
Value
=
"New"
PostBack
=
"false"
CausesValidation
=
"false"
meta:resourcekey
=
"ToolBarNew"
/>
</
Items
>
</
telerik:RadToolBar
>
I am still in a telerik evaluation phase and working with an evaluation copy.
I am very new to web-application development, so forgive me if my question is dump.
From a record-selection form I want to allow the user to call multiple update forms.
This works without problems.
But if I close one or all of the individual update forms and than call up additionally update-forms, all the previously created forms are popping up again. What have I forgotten?
To demonstrate my problem see the following example.
Just press the [New RadWindow] button multiple times.
Then close all created windows by pressing [Close Window].
When you then press the [New RadWindow] all the previously created forms and a new one are showing.
How can I supress the showing of previusly closed forms?
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Default" %>
<!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
></
title
>
<
telerik:RadStyleSheetManager
id
=
"RadStyleSheetManager1"
runat
=
"server"
/>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
>
<
Scripts
>
<%--Needed for JavaScript IntelliSense in VS2010--%>
<%--For VS2008 replace RadScriptManager with ScriptManager--%>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.Core.js"
/>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.jQuery.js"
/>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.jQueryInclude.js"
/>
</
Scripts
>
</
telerik:RadScriptManager
>
<
script
type
=
"text/javascript"
>
//Put your JavaScript code here.
</
script
>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
</
telerik:RadAjaxManager
>
<
div
>
<
telerik:RadWindowManager
ID
=
"RadWindowManager1"
runat
=
"server"
>
</
telerik:RadWindowManager
>
</
div
>
<
telerik:RadButton
ID
=
"RadButton1"
runat
=
"server"
onclick
=
"RadButton1_Click"
Text
=
"New RadWindow"
>
</
telerik:RadButton
>
<
asp:RadioButtonList
ID
=
"RadioButtonList1"
runat
=
"server"
>
<
asp:ListItem
>use Form.Controls.Add</
asp:ListItem
>
<
asp:ListItem
Selected
=
"True"
>use RadWindowManager.Add</
asp:ListItem
>
</
asp:RadioButtonList
>
</
form
>
</
body
>
</
html
>
using
System;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Data;
using
System.Configuration;
using
System.Web.Security;
using
System.Web.UI.WebControls.WebParts;
using
System.Web.UI.HtmlControls;
using
Telerik.Web.UI;
public
partial
class
Default : System.Web.UI.Page
{
public
static
int
Counter = 0;
protected
void
Page_Load(
object
sender, EventArgs e)
{
}
protected
void
RadButton1_Click(
object
sender, EventArgs e)
{
RadWindow window1 =
new
RadWindow();
window1.NavigateUrl =
"WebForm2.aspx"
;
window1.ID =
string
.Format(
"NonModalForm{0}"
, Counter++.ToString());
window1.Title = window1.ID;
window1.Behaviors = Telerik.Web.UI.WindowBehaviors.Close
| Telerik.Web.UI.WindowBehaviors.Resize
| Telerik.Web.UI.WindowBehaviors.Move;
window1.Top = 80 + Counter * 20;
window1.Left = Counter * 20;
window1.Width = 200;
window1.Height = 100;
window1.Modal =
false
;
window1.KeepInScreenBounds =
true
;
// false; // seem to have no effect ( tested with IE );
window1.VisibleStatusbar =
false
;
window1.ShowContentDuringLoad =
false
;
window1.EnableViewState =
true
;
// false;
window1.DestroyOnClose =
false
;
// if true I get error in my real app.
window1.VisibleOnPageLoad =
true
;
switch
(RadioButtonList1.SelectedValue)
{
case
"use Form.Controls.Add"
:
this
.Form.Controls.Add(window1) ;
break
;
// this will show the window - but did not show multiple non-modal windows.
case
"use RadWindowManager.Add"
: RadWindowManager1.Windows.Add(window1);
break
;
// RadWindowManager needed to show multiple non-modal windows - but Manager did not release windows.
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="RadControlsWebApp_FormFLow.WebForm2" %>
<!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
></
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
div
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
Runat
=
"server"
>
</
telerik:RadScriptManager
>
<
telerik:RadCodeBlock
id
=
"RadCodeBlock1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function GetRadWindow() {
var oWindow = null;
if (window.radWindow) oWindow = window.radWindow;
else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
return oWindow;
}
</
script
>
</
telerik:RadCodeBlock
>
<
telerik:RadButton
ID
=
"RadButton1"
runat
=
"server"
Text
=
"Close Form"
onclick
=
"RadButton1_Click"
>
</
telerik:RadButton
>
</
div
>
</
form
>
</
body
>
</
html
>
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
RadControlsWebApp_FormFLow;
namespace
RadControlsWebApp_FormFLow
{
public
partial
class
WebForm2 : System.Web.UI.Page
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
}
protected
void
RadButton1_Click(
object
sender, EventArgs e)
{
// close RadWindow
ClientScript.RegisterStartupScript(GetType()
,
"WindowCloseScript"
,
"<script type='text/javascript'> var oWindow = GetRadWindow(); oWindow.Close(); </script>"
);
}
}
}
public class ShowContactPhoto : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
int iContactID = Convert.ToInt32(context.Request.QueryString["ContactID"]);
Stream strm = showContactImage(iContactID);
byte[] buffer = new byte[4096];
int byteSeq = strm.Read(buffer, 0, 4096);
while (byteSeq > 0)
{
context.Response.OutputStream.Write(buffer, 0, byteSeq);
byteSeq = strm.Read(buffer, 0, 4096);
}
}
public Stream showContactImage(int iContactID)
{
Individual_Contacts_BLL bllContact = new Individual_Contacts_BLL();
Individual_Contacts_BO boContact = new Individual_Contacts_BO();
boContact.Contact_ID = iContactID;
DataTable dt = bllContact.selectContactPhoto(ref boContact);
object img = dt.Rows[0]["Contact_Photo"];
try
{
return new MemoryStream((byte[])img);
}
catch
{
return null;
}
// return null;
}
public bool IsReusable
{
get
{
return false;
}
}
}
Also, user can edit contact information, and also in the photo, i do the edit in another page opened in a Radwindow....all is fine and all the data is updated in database even the image, i call the grid rebind via an ajax request and also the grud is refreshed...BUT, neither the image control in the edit window page and the cloumn in the radgrid is refreshed until i call the page again!!!!
i debug the code, and the ImageURL is rewritten but the ShowContactPhoto.ashx is not called again until i call the whole page which holds the grid again!!!
i tried to send a random number within the url so not called from the cash,,, but still not called!!!
how can i acheive this, i need to show the updated image in the edit window and the grid without the need to call the page again!!!
any help will be geat...
thanks
asa'ad
Installed Telerik components: RadControls for ASP.NET AJAX Q2 2011 SP1
Text:
I created two projects, a WFC Service (name: PartialProjectServiceAjaxTest) and a Web Application (name: PartialProjectASPXAjaxTest).
The service in his basic form, was a copy of the code on http://demos.telerik.com/aspnet-ajax/combobox/examples/populatingwithdata/linqdatasource/defaultcs.aspx.
The important changes in the code:
- Add a list <person> and read this list with LINQ
The aspx in his basic form, was a copy of http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/autocompleteclientside/defaultcs.aspx
The important changes in the code:
- add RadScriptManager1
- <WebServiceSettings Path="http://localhost:54266/Service1.svc" Method="LoadData" /></telerik:RadComboBox> (54266 is the used port)
When i deploy the projects, it’s possible to see the UI, but when i will show up the results of the service, in the ComboBox, i will get an error message:
‘The server method ’LoadData’ failed’
This message is parsed right after clicking the textbox in the UI.
Testing:
- First i created a console app to test the service. Because i could load the data, the service doesn’t generate the error;
- Then i commented the code that filter the results. I need data anyway and will filter them in a later stage. I got the same error;
-Debugging both of the projects doesn’t give any explanation;
My question is: Why isn’t it possible for me to load the LoadData method in my Web app in case of a good functioning service?
The most inportant code:
LodWebService.aspx:____________________________________________________________________________________________________
<%
@ Page Language="C#" AutoEventWireup="true" CodeBehind="LodWebService.aspx.cs" Inherits="LodWebService" %>
<%
@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!
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 id="Head1" runat="server">
<title></title>
<style type="text/css">
span.text
{
font: 13px 'Segoe UI' , Arial, sans-serif;
color: #4888a2;
padding-right: 10px;
vertical-align: middle;
display: inline-block;
*
display:inline;
zoom:1;
width:90px;
}
.module-row
{
margin: 10px 0;
}
.module-row .status-text
{
margin-left: 103px;
display: block;
font: 13px 'Segoe UI' , Arial, sans-serif;
color: #4888a2;
}
</style>
<telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" />
</
head>
<
body>
<form id="form1" runat="server">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
<Scripts>
<%
--Needed for JavaScript IntelliSense in VS2010--%>
<%
--For VS2008 replace RadScriptManager with ScriptManager--%>
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
</Scripts>
</telerik:RadScriptManager>
<script type="text/javascript">
//Put your JavaScript code here.
</script>
<div class="module-row">
<span class="text"></span>
<telerik:RadComboBox ID="RadComboBox1" runat="server" Width="400px" Height="150px"
EmptyMessage="E-mail adres / Achternaam / Voornaam" EnableLoadOnDemand="true" ShowMoreResultsBox="true"
EnableVirtualScrolling="true">
<WebServiceSettings Path="http://localhost:54266/Service1.svc" Method="LoadData" />
</telerik:RadComboBox>
<asp:Button runat="server" Text="Select" ID="Button1" OnClick="Button1_Click">
</asp:Button>
</div>
<div class="module-row">
<asp:Label CssClass="status-text" ID="Label1" runat="server"></asp:Label>
</div>
</form>
</
body>
</
html>
Service1.svc:____________________________________________________________________________________________________
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Runtime.Serialization;
using
System.ServiceModel;
using
System.Text;
using
System.ServiceModel.Activation;
using
Telerik.Web.UI;
namespace
partialProjectServiceAjaxTest
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
[
AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Service1 : IService1
{
public class person
{
public string firstname;
public string lastname;
}
RadComboBoxData IService1.LoadData(RadComboBoxContext context)
{
//The RadComboBoxData object contains all required information for load on demand:
// - the items
// - are there more items in case of paging
// - status message to be displayed (which is optional)
RadComboBoxData result = new RadComboBoxData();
/// NorthwindDataContext northwind = new NorthwindDataContext();
List<person> persons = new List<person>();
persons.Add(
new person { firstname = "Bernard", lastname = "C" });
persons.Add(
new person { firstname = "Theo", lastname = "C" });
persons.Add(
new person { firstname = "Bryan", lastname = "C" });
persons.Add(
new person { firstname = "Tim", lastname = "C" });
//Get all items from the Customers table. This query will not be executed untill the ToArray method is called.
var allCustomers = from customer in persons
orderby customer.firstname
select new RadComboBoxItemData
{
Text = customer.firstname
};
////In case the user typed something - filter the result set
//string text = context.Text;
//if (!String.IsNullOrEmpty(text))
//{
// allCustomers = allCustomers.Where(item => item.Text.StartsWith(text));
//}
////Perform the paging
//// - first skip the amount of items already populated
//// - take the next 10 items
//int numberOfItems = context.NumberOfItems;
//var customers = allCustomers.Skip(1).Take(10);
////This will execute the database query and return the data as an array of RadComboBoxItemData objects
//result.Items = customers.ToArray();
//int endOffset = numberOfItems + customers.Count();
//int totalCount = allCustomers.Count();
////Check if all items are populated (this is the last page)
//if (endOffset == totalCount)
// result.EndOfItems = true;
//////Initialize the status message
//result.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>",
// endOffset, totalCount);
result.Items = allCustomers.ToArray();
return result;
}
}
}
IService1.cs:_________________________________________________________________________________
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Runtime.Serialization;
using
System.ServiceModel;
using
System.Text;
using
Telerik.Web.UI;
namespace
partialProjectServiceAjaxTest
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
[
ServiceContract]
public interface IService1
{
[
OperationContract]
RadComboBoxData LoadData(RadComboBoxContext context);
}
}
<
telerik:RadGrid
ID
=
"RadGridSearchDog"
runat
=
"server"
GridLines
=
"None"
Height
=
"460px"
Width
=
"740px"
AutoGenerateColumns
=
"False"
OnPreRender
=
"RadGrid_PreRender"
EnableEmbeddedSkins
=
"False"
AllowSorting
=
"True"
Culture
=
"ru-RU"
>
<
ClientSettings
>
<
DataBinding
FilterParameterType
=
"Linq"
Location
=
"FinanceService.asmx"
SelectMethod
=
"GetDogovorDataLinq"
SortParameterType
=
"Linq"
>
</
DataBinding
>
<
Selecting
AllowRowSelect
=
"True"
/>
<
ClientEvents
OnCommand
=
"function(){}"
OnRowDblClick
=
"OnRowDblClickDogGrid"
OnDataBinding
=
"RadGridDogovor_DataBinding"
OnDataBound
=
"OnDataBoundGridDog"
OnRowDataBound
=
"OnRowDataBoundDog"
/>
<
Scrolling
AllowScroll
=
"True"
UseStaticHeaders
=
"True"
/>
</
ClientSettings
>
<
MasterTableView
ClientDataKeyNames
=
"CTR_ID"
NoMasterRecordsText
=
"Нет данных для отображения"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"CTR_ID"
HeaderText
=
"Код"
UniqueName
=
"CTR_ID"
Visible
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"CTR_NUM"
HeaderText
=
"№ Договора"
UniqueName
=
"CTR_NUM"
>
<
HeaderStyle
Width
=
"120px"
></
HeaderStyle
>
<
ItemStyle
Width
=
"120px"
></
ItemStyle
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"CTR_DATE_REG"
HeaderText
=
"Регистрация"
DataType
=
"System.DateTime"
UniqueName
=
"CTR_DATE_REG"
DataFormatString
=
"{0:dd.MM.yyyy}"
Visible
=
"false"
>
<
HeaderStyle
HorizontalAlign
=
"Center"
></
HeaderStyle
>
<
ItemStyle
HorizontalAlign
=
"Right"
></
ItemStyle
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"CTR_CONTENT"
HeaderText
=
"Содержание"
UniqueName
=
"CTR_CONTENT"
>
<
HeaderStyle
Width
=
"400px"
></
HeaderStyle
>
<
ItemStyle
Width
=
"400px"
></
ItemStyle
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"CTR_STATUS_EXPLAINED"
HeaderText
=
"Статус"
UniqueName
=
"CTR_STATUS_EXPLAINED"
>
<
HeaderStyle
Width
=
"100px"
></
HeaderStyle
>
<
ItemStyle
Width
=
"100px"
></
ItemStyle
>
</
telerik:GridBoundColumn
>
<
telerik:GridCalculatedColumn
DataFields
=
"CTR_AMOUNT"
HeaderText
=
"Сумма"
DataType
=
"System.Decimal"
UniqueName
=
"CTR_AMOUNT"
Expression
=
"{0}"
SortExpression
=
"CTR_AMOUNT"
>
<
HeaderStyle
Width
=
"100px"
HorizontalAlign
=
"Center"
></
HeaderStyle
>
<
ItemStyle
Width
=
"100px"
HorizontalAlign
=
"Right"
></
ItemStyle
>
</
telerik:GridCalculatedColumn
>
</
Columns
>
</
MasterTableView
>
* * *
Best regards,
Maxim