Hello!
I'd been searching for a couple of days to find a solution to what is think is a "simple" problem, that due to my lack of knowledge is toooo hard to solve it without help.
What i need to accomplish is:
Open a RadWindow with my login page,
Get the login and password
Authenticate
-if succeed: redirect
-if fails: display a message ( i have label for that purpose) and keep the RadWindow open.
My problem is that i can't find a way to process the authentication and automatically close the window and redirect.
Because client-side functions run before server-side, i can't perform the authentication in my db and then execute the JavaScript functions with the same button. I know I can look for a javascript snippet to perform the authentication, but i don't want to take that path 'cause at this point i'm blind to javascript. so i want to reduce it at the very minimum possible. I'd tried the techniques to execute JS functions from code-behind with no luck. Even run sever-side functions from JS but i just can't make it work.
What i have so far:
Parent Page
Child Page aspx
The hidden-Field and RadButtons
Code-Behind
The problem with my code is that i have to click twice in the "btnLogin".
In the first click everything will run, but the client-side will execute first and nothing will happen in that side. At the same time if credentials are ok the hidden field will be populated.
In the second click: Again everything will run this time as expected.
For any help
Thanks in advance
I'd been searching for a couple of days to find a solution to what is think is a "simple" problem, that due to my lack of knowledge is toooo hard to solve it without help.
What i need to accomplish is:
Open a RadWindow with my login page,
Get the login and password
Authenticate
-if succeed: redirect
-if fails: display a message ( i have label for that purpose) and keep the RadWindow open.
My problem is that i can't find a way to process the authentication and automatically close the window and redirect.
Because client-side functions run before server-side, i can't perform the authentication in my db and then execute the JavaScript functions with the same button. I know I can look for a javascript snippet to perform the authentication, but i don't want to take that path 'cause at this point i'm blind to javascript. so i want to reduce it at the very minimum possible. I'd tried the techniques to execute JS functions from code-behind with no luck. Even run sever-side functions from JS but i just can't make it work.
What i have so far:
Parent Page
<script language=
"javascript"
type=
"text/javascript"
>
function
OpenLogin()
{
var
wnd = $find(
"<%=dlgLogin.ClientID%>"
);
wnd.setUrl(
"Login.aspx"
);
wnd.show();
}
function
IsOk(wnd, Arg) {
var
args = Arg.get_argument();
if
(args) {
window.location =
"CustomerStatus.aspx"
;
}
}
</script>
Child Page aspx
<script language=
"javascript"
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;
}
function
CancelWindow() {
var
wnd = GetRadWindow();
wnd.close();
}
function
CloseWndw() {
var
arg = document.getElementById(
"txtIsOk"
).value;
if
(arg) {
var
wnd = GetRadWindow();
wnd.close(arg);
}
}
function
Waiting(s, e)
{
Callback.PerformCallback();
LPWaitConn.Show();
}
</script>
The hidden-Field and RadButtons
<
asp:ScriptManager
ID
=
"ScriptManager1"
runat
=
"server"
>
</
asp:ScriptManager
>
<
asp:UpdatePanel
ID
=
"UpdatePanel1"
runat
=
"server"
>
<
ContentTemplate
>
<
asp:HiddenField
ID
=
"txtIsOk"
runat
=
"server"
/>
<
telerik:RadButton
ID
=
"btnLogin"
runat
=
"server"
Text
=
"Submit"
Style="z-index: 1;
left: 243px; top: 134px; position: absolute; height: 19px"
BackColor
=
"Transparent"
Font-Names
=
"Verdana"
Font-Size
=
"10pt"
ForeColor
=
"#84DA2E"
SkinID
=
"Black"
OnClientClicking
=
"Waiting"
OnClick
=
"btnLogin_Click"
OnClientClicked
=
"CloseWndw"
>
</
telerik:RadButton
>
<
telerik:RadButton
ID
=
"btnCancel"
runat
=
"server"
Text
=
"Cancel"
Style="z-index: 1;
left: 180px; top: 134px; position: absolute; height: 19px"
BackColor
=
"Transparent"
Font-Names
=
"Verdana"
Font-Size
=
"10pt"
ForeColor
=
"#84DA2E"
Font-Bold
=
"True"
Skin
=
"Black"
EnableViewState
=
"False"
OnClientClicked
=
"CancelWindow"
>
</
telerik:RadButton
>
</
ContentTemplate
>
</
asp:UpdatePanel
>
Code-Behind
Protected
Sub
btnLogin_Click(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
btnLogin.Click
Dim
strCon
As
String
=
String
.Empty
Dim
cnn
As
SqlConnection
If
Me
.txtIsOk.Value.Length > 0
Then
Exit
Sub
'Because of the forced postback this is avoid more than one execution
If
Me
.txtUser.Text.Length > 0
AndAlso
Me
.txtPass.Text.Length > 0
Then
strCon =
"Data Source=MyServer;Initial Catalog=MyDb;User Id="
&
Me
.txtUser.Text &
";Password="
&
Me
.txtPass.Text &
";"
cnn =
New
SqlConnection(strCon)
Try
cnn.Open()
Me
.txtIsOk.Value =
"Yes"
Catch
ex
As
SqlException
Me
.lblWarning.Text =
"Wrong Login or Password"
Me
.lblWarning.Visible =
True
Catch
ex1
As
Exception
Me
.lblWarning.Text =
"Wrong Login or Password"
Me
.lblWarning.Visible =
True
Finally
cnn.Close()
cnn.Dispose()
End
Try
End
If
End
Sub
In the first click everything will run, but the client-side will execute first and nothing will happen in that side. At the same time if credentials are ok the hidden field will be populated.
In the second click: Again everything will run this time as expected.
For any help
Thanks in advance