Hi,
In my application I have some simple asp:formviews for changing some settings of a specific record. In this case the password.
The form has three buttons, one for the formviews canceling event, one for the formviews update event and one which do some other staff on the server-side.
The two password textboxes requires validation done by the RadInputManager.
The TextBoxSettings are appended in the formiews ItemCreated event.
When calling the page the first time all looks fine, validation works and skins are applied. After clicking the update or the cancel button the TextBoxSettings are not appended to the textboxes and there is no validation.
On the other hand, when I click on the third button all works fine.
Has anyone an idea what I'm doing wrong? Is there an Rad equal to asp:formview ? How are others editng forms? Please note the this is only a small example. I have a lot of more complex asp:formviews in my app
Here ist my code
And code behind:
In my application I have some simple asp:formviews for changing some settings of a specific record. In this case the password.
The form has three buttons, one for the formviews canceling event, one for the formviews update event and one which do some other staff on the server-side.
The two password textboxes requires validation done by the RadInputManager.
The TextBoxSettings are appended in the formiews ItemCreated event.
When calling the page the first time all looks fine, validation works and skins are applied. After clicking the update or the cancel button the TextBoxSettings are not appended to the textboxes and there is no validation.
On the other hand, when I click on the third button all works fine.
Has anyone an idea what I'm doing wrong? Is there an Rad equal to asp:formview ? How are others editng forms? Please note the this is only a small example. I have a lot of more complex asp:formviews in my app
Here ist my code
<%@ Page Title="" Language="C#" MasterPageFile="~/portal/PartnerPersSettings.master" AutoEventWireup="true" CodeFile="PartnerAccess.aspx.cs" Inherits="www.sw_xperts.com.portal.PartnerAccess" %>
<
asp:Content
ID
=
"Content1"
ContentPlaceHolderID
=
"cpPersSettingContent"
runat
=
"server"
>
<
asp:HiddenField
id
=
"hfEditingPartnerId"
runat
=
"server"
/>
<
telerik:RadFormDecorator
ID
=
"rfdDefault"
runat
=
"server"
/>
<
telerik:RadAjaxManager
ID
=
"ramManager"
runat
=
"server"
EnablePageHeadUpdate
=
"False"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"fvZugangsdaten"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"fvZugangsdaten"
LoadingPanelID
=
"ralpLoading"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"rimAccess"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
telerik:RadAjaxLoadingPanel
id
=
"ralpLoading"
runat
=
"server"
></
telerik:RadAjaxLoadingPanel
>
<
telerik:RadInputManager
ID
=
"rimAccess"
runat
=
"server"
>
<
telerik:TextBoxSetting
BehaviorID
=
"behTxtRequired"
Validation-IsRequired
=
"true"
>
</
telerik:TextBoxSetting
>
</
telerik:RadInputManager
>
<
asp:FormView
CellPadding
=
"0"
CellSpacing
=
"0"
ID
=
"fvZugangsdaten"
DataKeyNames
=
"cp_id"
DefaultMode
=
"Edit"
runat
=
"server"
DataSourceID
=
"odsZugangsdaten"
onitemcreated
=
"fvZugangsdaten_ItemCreated"
>
<
EditItemTemplate
>
<
div
class
=
"editForm"
>
<
div
>
<
fieldset
style
=
"width:725px;"
>
<
div
class
=
"fieldsetTopSpacer"
></
div
>
<
ul
>
<
li
>
<
asp:Label
ID
=
"lblZdUsername"
runat
=
"server"
>Benutzername</
asp:Label
>
<
asp:HiddenField
ID
=
"hfZdUsername"
runat
=
"server"
Value='<%# Bind("DBUSER") %>' />
</
li
>
<
li
class
=
"inputBox"
>
<%# Eval("DBUSER") %>
</
li
>
<
li
style
=
"width:50%;text-align:right;"
>
<
asp:Button
ID
=
"btnZugangsdatenNeu"
runat
=
"server"
Text
=
"Benutzerkennung anlegen"
CommandName
=
"ZugangsdatenNeu"
CausesValidation
=
"false"
onclick
=
"btnZugangsdatenNeu_Click"
/>
</
li
>
</
ul
>
<
ul
>
<
li
>
<
asp:Label
ID
=
"lblZdPasswortNeu1"
runat
=
"server"
>Neues Passwort*</
asp:Label
>
</
li
>
<
li
>
<
asp:TextBox
ID
=
"txtPasswort1"
runat
=
"server"
TextMode
=
"Password"
Text='<%# Bind("Passwort") %>'></
asp:TextBox
>
</
li
>
</
ul
>
<
ul
>
<
li
>
<
asp:Label
ID
=
"lblZdPasswortNeu2"
runat
=
"server"
>Wiederholung*</
asp:Label
>
</
li
>
<
li
>
<
asp:TextBox
ID
=
"txtPasswort2"
runat
=
"server"
TextMode
=
"Password"
></
asp:TextBox
>
</
li
>
<
li
>
<
asp:CompareValidator
ID
=
"comparePasswort"
runat
=
"server"
ControlToCompare
=
"txtPasswort1"
ControlToValidate
=
"txtPasswort2"
Display
=
"Static"
ErrorMessage
=
"Passwörter nicht gleich"
></
asp:CompareValidator
>
</
li
>
</
ul
>
<
ul
>
<
li
>
<
asp:Label
ID
=
"testOut"
runat
=
"server"
></
asp:Label
>
</
li
>
</
ul
>
<
ul
style
=
"clear:both;"
>
<
li
style
=
"width:100%; text-align:right; height:auto;clear:both;"
>
<
asp:Button
ID
=
"btnUpdate"
runat
=
"server"
Text
=
"Speichern"
CommandName
=
"Update"
CausesValidation
=
"true"
/>
<
asp:Button
ID
=
"btnCancel"
runat
=
"server"
Text
=
"Abbrechen"
CommandName
=
"Cancel"
CausesValidation
=
"false"
/>
</
li
>
</
ul
>
</
fieldset
>
</
div
>
</
div
>
</
EditItemTemplate
>
</
asp:FormView
>
<
asp:ObjectDataSource
ID
=
"odsZugangsdaten"
runat
=
"server"
SelectMethod
=
"getZugangsdaten"
UpdateMethod
=
"setZugangsdaten"
OldValuesParameterFormatString
=
"original_{0}"
TypeName
=
"com.swxperts.corelib.bo.ModPersoenlicheDaten"
>
<
SelectParameters
>
<
asp:SessionParameter
Name
=
"LoggedInProfilId"
SessionField
=
"LoggedInUser"
Type
=
"String"
/>
<
asp:ControlParameter
ControlID
=
"hfEditingPartnerId"
DefaultValue
=
""
Name
=
"ProfilId"
PropertyName
=
"Value"
Type
=
"String"
/>
<
asp:SessionParameter
Name
=
"DbSession"
SessionField
=
"SessionTracker"
Type
=
"String"
/>
</
SelectParameters
>
<
UpdateParameters
>
<
asp:SessionParameter
Name
=
"LoggedInProfilId"
SessionField
=
"LoggedInUser"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"Original_cp_id"
Type
=
"String"
/>
<
asp:SessionParameter
Name
=
"DbSession"
SessionField
=
"SessionTracker"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"DBUser"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"Passwort"
Type
=
"String"
/>
</
UpdateParameters
>
</
asp:ObjectDataSource
>
</
asp:Content
>
And code behind:
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
Telerik.Web.UI;
namespace
www.sw_xperts.com.portal {
public
partial
class
PartnerAccess : ExtendedPage {
protected
void
Page_Load(
object
sender, EventArgs e) {
if
(!IsPostBack) {
string
EditingId = Request.QueryString.Get(
"ProfilId"
);
hfEditingPartnerId.Value =
string
.IsNullOrEmpty(EditingId) ? Session[
"LoggedInUser"
]
as
string
: EditingId;
}
if
(
string
.IsNullOrEmpty(hfEditingPartnerId.Value)) {
Response.Redirect(
"~/Default.aspx"
);
}
}
protected
void
fvZugangsdaten_ItemCreated(
object
sender, EventArgs e) {
FormView fv = (FormView)sender;
if
(fv.CurrentMode == FormViewMode.Edit) {
TextBox txtPasswort1 = fv.FindControl(
"txtPasswort1"
)
as
TextBox;
TextBox txtPasswort2 = fv.FindControl(
"txtPasswort2"
)
as
TextBox;
TextBoxSetting reqTextBoxSetting = (TextBoxSetting)rimAccess.GetSettingByBehaviorID(
"behTxtRequired"
);
reqTextBoxSetting.TargetControls.Add(
new
TargetInput(txtPasswort1.UniqueID,
true
));
reqTextBoxSetting.TargetControls.Add(
new
TargetInput(txtPasswort2.UniqueID,
true
));
}
}
protected
void
btnZugangsdatenNeu_Click(
object
sender, EventArgs e) {
Button a = sender
as
Button;
Label l = a.NamingContainer.FindControl(
"testOut"
)
as
Label;
l.Text =
"Clicked and done"
;
}
}
}