Richiamare un oggetto activex dopo un'autenticazione..

venerdì 12 febbraio 2010 - 11.20

paolaa Profilo | Newbie

Salve, ho un activex che si chiama obj1, già fatto e devo integrarlo nella mia pagina aspx
dopo un'autenticazione su db sqlserver 2008 expr.
Il problema è che non so come attivare l'activex in seguito all'autenticazione.
In origine la pagina era un PagLogin.html dove il Login button lanciava la funzione OnLogin(..) (vedi codice sotto)

L'ideale sarebbe di lanciare lo script OnLogin(..) dopo l'esecuzione dell'evento "btn_login_Click" scatenato dal bottone asp, ma non riesco.
Spero di essere stata chiara e soprattutto che qualcuno possa aiutarmi.
Segue il codice.
Grazie intanto
Paola

La mia pagina aspx è come segue (il codice l'ho recuperato da un esempio fornito dalla documentazione di questo activex)


%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PagLogin.aspx.cs" Inherits="prog.PagLogin" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<!-- saved from url=(0014)about:internet -->
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Custom Login Screen Sample</title>

<SCRIPT src="obj1Config.js" ></SCRIPT>

<SCRIPT Language="JavaScript">
<!--
var L_strLoginError_Message = "Error Logging in.";
// Initialize control

function Init()
{
//Note: Change iSiteConfig.js file for your iSite settins.
document.getElementById("<%=uname.ClientID %>").value = obj1.User.UserName;
document.getElementById("<%=pword.ClientID %>").value = obj1.User.Password;

obj1.iSyntaxServerIP = xxxxxxxx;
obj1.ImageSuiteDSN = xxxxxxxx;
obj1.ImageSuiteURL = o xxxxxxxx;
obj1.Options = "......."; //obj1.Server.Options;

// Always initialize the non-visual control first
test = obj1.Initialize();
if (!test)
alert("Failed to initialize the iSite Non-Visual Control");
else
obj1.style.display = "none"

}
function OnLogin(user, password)
{
if ((obj1.SecurityCodes!="")|| (obj1.Login("Administrator","","obj1", "", "")))
{
// hide the login screen
LoginTable.style.display = "none";

// show the iSiteEnterprise control through re-sizing (fit to screen)
obj1.Options = "StentorBackEnd,DisableAutoLogout,HideFolders,HideCloseTabButton,DisablePreferences";
obj1.style.display = "inline";
obj1.Initialize();
}
else
{
alert(L_strLoginError_Message);
}
}
//-->
</SCRIPT>

<SCRIPT LANGUAGE="JavaScript" FOR=iSite EVENT="EventLogout(AutoLogoutFlag)">

// hide the iSite control
obj1.style.display = "none";

// show the login screen
LoginTable.style.display = "inline";

</SCRIPT>

</head>

<body onload="Init()">
<p>

<OBJECT id="obj1"
CLASSID = "clsid:DD0zzzzzzzzzzzzzzzzz"
width=0%
height=0%>
</OBJECT>

</p>
<DIV id="LoginTable">
<form id="Form1" runat="server">
<table BORDER="0" WIDTH="400" BGCOLOR="#bbc5ca" CELLPADDING="4" CELLSPACING="0" align="center">
<TR><TD HEIGHT="167" ALIGN="center">
<table BORDER="0" CELLPADDING="0" CELLSPACING="0">
<TR>
<TD COLSPAN="2" VALIGN="top" height=30>
Per favore introdurre il nome di login e la password<BR></TD>
</TR>
<TR>
<TD ALIGN="right">Username:</TD><TD ALIGN="left" style="width: 225px">&nbsp;
<asp:TextBox ID="uname" runat="server"></asp:TextBox></TD>
</TR>
<TR>
<TD ALIGN="right">Password:</TD>
<TD ALIGN="left" style="width: 225px">&nbsp;
<asp:TextBox ID="pword" runat="server"></asp:TextBox></TD>
</TR>
<TR>
<TD ALIGN="right" style="height: 24px"></TD>
<TD ALIGN="left" style="height: 24px; width: 225px;"> </TD>
</TR>
<TR>
<TD HEIGHT="31">&nbsp;</TD>
<TD HEIGHT="31" align="center" style="width: 225px">
</TR>
</table>

<asp:Button ID="btn_login" runat="server" Text="Login" Width="111px" OnClick="btn_login_Click" />

/*** Bottone originario
<INPUT TYPE="button" VALUE=" Login " NAME="submitbtn" onclick="OnLogin(uname.value, pword.value)" style="width: 113px">
***** /

</table>
</form>
</DIV>
</body>

</html>

******************** Codice aspx.cs
public partial class PagLogin : System.Web.UI.Page
{
string ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["xxConnectionString"].ConnectionString;

protected void Page_Load(object sender, EventArgs e)
{
}

protected void btn_login_Click(object sender, EventArgs e)
{
using (SqlConnection connection = new SqlConnection(ConnectionString))
{
connection.Open();
string us = Request.Form["uname"];
string pw = Request.Form["pword"];
string sql = "select * from utenti where ad_user ='" + us.Trim() + "' and ( UserPsw ='" + pw.Trim() + "' or UserPsw is null) ";
SqlCommand cmd = new SqlCommand(sql, connection);
SqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
string username = rdr["ad_user"].ToString();
string password = rdr["UserPsw"].ToString();

/******** CHIAMATA ALL " OGGETTO OBJ1 " */
}

rdr.Close();
connection.Close();
}
}

Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5