|
You're welcome...
Happy coding
<< >>
|
|
|
|
|
sir,
how can i send sms to any number accross the country.i just want to use this feature in my web application.is it possible.if possible than how can i do it.
|
|
|
|
|
You might ask your service provider to check if they support sending sms to a particular country or not...
<< >>
|
|
|
|
|
i want to add this feature in my project.
as see one of site provde this feature.i want to know how i do it.
|
|
|
|
|
Do they expose as web service? if so, just make a client call their services
<< >>
|
|
|
|
|
|
hi all,
How can we access a particular file or folder on the clients machine using a ASP.NET web application ? Accessing of the file will be done with client's permission. I s there any way for it?
Thanks and regards,
Anjon
|
|
|
|
|
anjon wrote: How can we access a particular file or folder on the clients machine using a ASP.NET web application ?
using
<br />
<input id="File1" type="file" runat="server" /><br />
and System.Web.UI.HtmlControls
anjon wrote: Accessing of the file will be done with client's permission.
Yes you should have permission
Thanks and Regards
Sandeep
If you want something you never had,
do something you have never done!
|
|
|
|
|
Hi
I have a Hidden Field in my First Form When i button click this hidden Field value should go to next page.
Pls tell me how to pass the value to url using ? Pls give me syntax
Thanks a lot,
|
|
|
|
|
Sagar i told you the solution for it i think
Let it be
siddisagar wrote: I have a Hidden Field in my First Form
Assign the value to hiddenfeild like
HiddenField1.Value = TextBox1.Text;
ok Now you can use this value in any page just by
string FirstPageValue= Request.Params[0];
ok Now try it
Thanks and Regards
Sandeep
If you want something you never had,
do something you have never done!
|
|
|
|
|
You can use query string...
<< >>
|
|
|
|
|
You can use Session as well to use it in other pages. Pass the hidden field value in Session.
LIKE:
Session.Add("SessionName",HiddenFieldValue); // C#
Session.Add("SessionName",HiddenFieldValue) ' VB.NET
To retrieve the value
Datatype name=(DataType)Session["SessionName"].ToString();
Hope this will help u
KHATRI
|
|
|
|
|
Hi,
I have a scenario which I need it in my website and I can't really type out in Google search, hehe, too complicated to search there.
The scenario is when I click on a button, a window should pop up (which I have no problem doing that), then I need to type something in the child window, close, then only the parent window execute the rest of the code.
My problem is when the child window pops up, the parent window already started executing the rest of the code. So, I was wondering is there anyway to ask the parent window to 'wait' until I close the child window?
Many thanks in advance
J Liang
|
|
|
|
|
using window.showModalDialog(...) method
Hope this helps
<< >>
|
|
|
|
|
Hi,
Thanks, it work fine, but can I know how to close this dialog box as I'd tried window.close but it doesn't work instead it open up a new window :P
J Liang
|
|
|
|
|
Hi,
Sorry, forgot to add this reply, I was wondering how can I return text value from the dialog box back to the parent window when it close?
J Liang
|
|
|
|
|
|
Hey,
Thanks, it's working fine.
J Liang
|
|
|
|
|
I've got an aspx page that contains a combo box with a selectedindexchanged event hooked up. My page also needs some javascript contained in an include file. Every time I select an item from the combobox i get an error:
__doPostBack is undefined.(reported by firebug(IE was much less helpful))
The code in the included js file is working and if i remove the reference to the included file the postback works ok. I've checked that i should be able to use multiple script tags in a document and that seems like it should work.
What do i have to do to get both scripts running at the same time?
Thanks
Russell
<head id="ctl00_DocHeader"><link href="FormStyle.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="account.js" />
<title>
</title></head>
<body>
<form name="aspnetForm" method="post" action="AccountViewer.aspx" id="aspnetForm">
<div>
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__LASTFOCUS" id="__LASTFOCUS" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="<very long string>" />
</div>
<script type="text/javascript">
<!--
var theForm = document.forms['aspnetForm'];
if (!theForm) {
theForm = document.aspnetForm;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
// -->
</script>
|
|
|
|
|
This is the code in my login.ascx file.
<%@ Import Namespace="System.Data" %> <br />
<%@ Import Namespace="System.Data.Sql" %><br />
<%@ Import Namespace="System.Data.SqlClient" %><br />
<%@ Import Namespace="System.Data.SqlTypes" %><br />
<br />
<br />
<script language="C#" runat="server"><br />
<br />
public String RedirectPage ="Overzicht.aspx";<br />
<br />
public int chk;<br />
<br />
bool Authenticate(String user, String pass) <br />
{ <br />
bool authenticated = false;<br />
try <br />
{ <br />
String dsn = "server=localhost;uid=sa;pwd=;database=db";<br />
String sSQL = "SELECT emailadres,paswoord FROM tblPersoneelslid WHERE (emailadres='" + UserName + "' AND paswoord='" + Password + "')";<br />
<br />
SqlConnection Conn = new SqlConnection(dsn); <br />
SqlCommand Cmd = new SqlCommand(sSQL,Conn); <br />
SqlDataReader Read1 = null;<br />
<br />
Conn.Open();<br />
<br />
Read1 = Cmd.ExecuteReader(); <br />
<br />
if (Read1!=null){<br />
<br />
if (Read1.Read()) <br />
{ <br />
if (Read1.GetString(0)==user)<br />
{<br />
if(Read1.GetString(1)==pass){<br />
authenticated =true;<br />
}<br />
else<br />
{<br />
chk=1;<br />
}<br />
}<br />
else<br />
{<br />
chk=2;<br />
}<br />
}<br />
}<br />
<br />
}<br />
catch(Exception e) <br />
{<br />
Response.Write("Foutmelding: " + e.ToString());<br />
}<br />
<br />
return authenticated;<br />
}<br />
<br />
private void SubmitBtn_Click(Object sender, EventArgs e) <br />
{ <br />
if (Authenticate(UserName.Text, Password.Value)) <br />
{ <br />
Response.Redirect(RedirectPage);<br />
}<br />
<br />
else <br />
{<br />
if (chk==1)<br />
{<br />
Message.Text="Paswoord ongeldig";<br />
UserMark.Visible = false;<br />
PasswordMark.Visible = true;<br />
Message.Visible = true;<br />
}<br />
else<br />
{<br />
Message.Text="Gebruikersnaam ongeldig";<br />
PasswordMark.Visible = false;<br />
UserMark.Visible = true;<br />
Message.Visible = true;<br />
}<br />
}<br />
}<br />
<br />
</script>
and the error i get is:
Foutmelding: System.Data.SqlClient.SqlException: Login failed for user 'sa'. at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.SqlClient.SqlConnection.Open() at ASP.login_ascx.Authenticate(String user, String pass) in d:\[ STAGE ]\Applicatie\WorkflowLibrary1\WebSite1\login.ascx:line 28
can someone help me with this problem?
-- modified at 4:07 Tuesday 24th April, 2007
|
|
|
|
|
Problems I noticed:
1. You're trying to log on to an SQL Server with 'sa' credentials.
2. You're code is open for SQL Injection.
3. SqlConnection should be opened in a try-catch block.
4. SqlDataReader should be closed after you retrive the data (either explicitly, or by specifíing the whole thing in a using statement.)
5. You just check is the SqlDataReader is created, but not if there's anything to read, so if there's no data, the GetString method will throw an excpetion.
6. You're using an unnecessary global variable chk.
7. You're shouldn't specify if the username or the password was incorrect. Just use some generic error message.
8. Don't let the user see the stack trace of an exception if thrown.
|
|
|
|
|
ty for the answer, but i have a new question now, i looked up for some new code and found this:
my login.aspx file:
<%@ Page Language="C#" %><br />
<%@ Import Namespace="System.Data" %><br />
<%@ Import Namespace="System.Data.OleDb" %><br />
<%@ Import Namespace="System.Web.Security" %><br />
<%@ Register TagPrefix="MySite" TagName="Login" Src="login.ascx" %><br />
<br />
<script language="C#" runat="server"><br />
private void Page_Load(Object sender, EventArgs E) <br />
{<br />
if ((Page.IsPostBack) && (Page.IsValid)) {<br />
string strDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Membership.mdb";<br />
string strSQL = "SELECT userName, userPassword FROM Membership WHERE userName='" + MyLogin.UserId + "'";<br />
<br />
OleDbConnection myConn = new OleDbConnection(strDSN);<br />
OleDbCommand myCmd = new OleDbCommand(strSQL, myConn);<br />
OleDbDataReader dr = null;<br />
try {<br />
myConn.Open();<br />
dr = myCmd.ExecuteReader();<br />
<br />
if(dr.Read()) {<br />
if(dr.GetString(1).Trim() == MyLogin.Password.Trim()) <br />
{<br />
FormsAuthentication.RedirectFromLoginPage(MyLogin.UserId, false);<br />
}<br />
else<br />
Message.Text = "Login mislukt. Probeer opnieuw";<br />
}<br />
else<br />
{<br />
Message.Text = "Login mislukt. Probeer opnieuw";<br />
}<br />
}<br />
catch(Exception myException) {<br />
Response.Write("Oops. The error: " + myException.Message);<br />
}<br />
finally {<br />
myConn.Close();<br />
}<br />
}<br />
}<br />
</script><br />
<html><br />
<body><br />
<h3>Login</h3><br />
<form runat="server" ID="Form1"><br />
<asp:Label id="Message" runat="server" /><br />
<MySite:Login id="MyLogin" BackColor="#FFFFCC" runat="server"/><br />
</form><br />
</body><br />
</html>
Is it possible to work with a OleDbConnection to connect to a SQL database?
thanks in advance
|
|
|
|
|
daviperke wrote: Is it possible to work with a OleDbConnection to connect to a SQL database?
Yes it is, but it's not recommended.
Note that in your new code problems 2 and 4 still remain. To solve 2 use a parametrized query and SqlParamaters. To solve 4 in the finally block write:
if (dr != null) dr.Close(); Also I don't recommend writing out any exception info. Use user-friendly messages to hide technical details.
|
|
|
|
|
Error: Could not use ''; file already in use.
this is the error i get when i fill in something and press login
code:
<%@ Page Language="C#" %><br />
<%@ Import Namespace="System.Data" %><br />
<%@ Import Namespace="System.Data.OleDb" %><br />
<%@ Import Namespace="System.Web.Security" %><br />
<%@ Register TagPrefix="MySite" TagName="Login" Src="login.ascx" %><br />
<br />
<script language="C#" runat="server"><br />
<br />
private void Page_Load(Object sender, EventArgs E) <br />
{<br />
if (Page.IsPostBack)
{<br />
string strDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\sql server 2005\\MSSQL.1\\MSSQL\\Data\\db.mdf";<br />
string strSQL = "SELECT emailadres, paswoord FROM tblPersoneelslid WHERE emailadres='" + MyLogin.UserId + "'";<br />
<br />
OleDbConnection myConn = new OleDbConnection(strDSN);<br />
OleDbCommand myCmd = new OleDbCommand(strSQL, myConn);<br />
OleDbDataReader dr = null;<br />
<br />
try<br />
{<br />
myConn.Open();<br />
dr = myCmd.ExecuteReader();<br />
<br />
if (dr.Read())<br />
{<br />
if (dr != null) dr.Close();<br />
{<br />
if (dr.GetString(1).Trim() == MyLogin.Password.Trim())<br />
{<br />
FormsAuthentication.RedirectFromLoginPage(MyLogin.UserId, false);<br />
}<br />
else<br />
{<br />
Message.Text = "Login mislukt. Probeer opnieuw";<br />
}<br />
}<br />
}<br />
else<br />
{<br />
Message.Text = "Login mislukt. Probeer opnieuw";<br />
}<br />
<br />
}<br />
catch (Exception myException)<br />
{<br />
Response.Write("Foutmelding: " + myException.Message);<br />
}<br />
finally<br />
{<br />
myConn.Close();<br />
}<br />
}<br />
}<br />
</script>
|
|
|
|
|
You can't connect to the database file itself, unless it is detached from SQL Server.
In my previous post I meant using OleDbConnection just like SqlConnection, that is connecting to the server.
|
|
|
|