|
|
my problem: this works fine in a asp.net project, but not in a winform project, so can anyone help me to "convert" this?
<br />
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)<br />
{<br />
bool Authenticated = false;<br />
Authenticated = SiteLevelCustomAuthenticationMethod(Login1.UserName, Login1.Password);<br />
e.Authenticated = Authenticated;<br />
if (Authenticated == true)<br />
{<br />
Response.Redirect("Overzicht.aspx");<br />
}<br />
}
|
|
|
|
|
Hi,
By winforms project, do you mean Windows Forms project(Windows application),
just curious.
Blumen
|
|
|
|
|
yes, i mean windows forms project, sorry
can anyone help me?
|
|
|
|
|
daviperke wrote: this works fine in a asp.net project, but not in a winform project, so can anyone help me to "convert" this?
What exactly is the problem? Are you trying to open a webpage from your winform?
daviperke wrote: Response.Redirect("Overzicht.aspx");
This shall work only in web forms. Your trying to redirect to a webpage from your winform, which cannot be done this way.
|
|
|
|
|
well, i want to use this code in my windows application, and it has nothing do to with the ASP.NET website anymore:
<br />
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)<br />
{<br />
bool Authenticated = false;<br />
Authenticated = SiteLevelCustomAuthenticationMethod(Login1.UserName, Login1.Password);<br />
e.Authenticated = Authenticated;<br />
if (Authenticated == true)<br />
{<br />
Response.Redirect("Overzicht.aspx");<br />
}<br />
}<br />
<br />
private bool SiteLevelCustomAuthenticationMethod(string UserName, string Password)<br />
{<br />
bool boolReturnValue = false;<br />
<br />
string strConnection = "server=blabla;database=db;Integrated Security=SSPI;";<br />
SqlConnection Connection = new SqlConnection(strConnection);<br />
String strSQL = "Select * From tblPersoneelslid";<br />
SqlCommand command = new SqlCommand(strSQL, Connection);<br />
SqlDataReader Dr;<br />
Connection.Open();<br />
Dr = command.ExecuteReader();<br />
while (Dr.Read())<br />
{<br />
if ((UserName == Dr["emailadres"].ToString()) & (Password == Dr["paswoord"].ToString()))<br />
{<br />
boolReturnValue = true;<br />
}<br />
Dr.Close();<br />
<br />
return boolReturnValue;<br />
}<br />
return false;<br />
}<br />
so when a user logged in correctly, he has to go to the page "frmMain.cs".
So the only think i ask is to help me a bit with "converting" the asp.net code into code i can use in my windows application.
|
|
|
|
|
In your btnLogin click event, create an object of frmMain and open it if the authentication is correct.
private void btnLogin_Click(object sender, System.EventArgs e)
{
frmMain objForm;
if(SiteLevelCustomAuthenticationMethod(txtUserName.Text, txtPassword.Text))
{
objForm = new frmMain();
objForm.Show();
}
}
Try to read articles on winforms. And post any related questions in c# of windows forms forum.
|
|
|
|
|
BTW delete the duplicate post.
|
|
|
|
|
I am currently having a few problems with a grid view I am working with. The gridview is set up to display a list of calls that have been received. This is populated via a view on the sql server database. I have a number of options on the page that I can filter the gridview on. The ides is that the user can click on a dropdown list and select some options and then click a button ‘apply’ which then composes a new query I then set this string (msg) to be the select command of the gridview using…
sqlGridView.SelectCommand = "SELECT * FROM [uvw_supportcalllist] " & msg <br />
GridView1.DataBind()
This applys the filter brilliantly…all is well and good so far. However I have set the paging attributes to true and set the pages length thing to be 20 now if I apply my filter like above and then go to the next page I lose my applied filter.
I realise I am missing something somewhere, I have attempted to call databind again in the paging event of the page but that doesn’t work. Can someone help me out? Am I applying my filter wrongly? Or is there a better of paging the gridview? Any help would be most appreciated.
Cheers
Ian Caddick
|
|
|
|
|
I am guessing there is a pretty good chance that you are doing an initial load in the page load event? If you have code like that you need to check to see if the page load is a postback or not. You would only want to call that code on the first page load, not on a post back which is what happens when you page. So check the IsPostback property of the page. You code would be something like:
If (!IsPostBack)
{
//Initial bind code here
}
Hope that helps.
Ben
|
|
|
|
|
Thanks but no, I already do that
I am in vb but its the same thing I do
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load<br />
If Not IsPostBack() Then<br />
Initialise()<br />
End If<br />
End Sub
Thanks for trying tho
Cheers
Cads
|
|
|
|
|
Hi all,
I am sending emails with attachments through my application.For this purpose i need to save the attachments on the server , attach them and then delete after sending the mail.The problem is i am not able to set the write permissions on the webapplication since there is no Security tab in the WebApplication folder`s properties.How can i bring in the security tab or is there any other method of giving write perm.
|
|
|
|
|
Look for 'simple file sharing' in your folder options and turn it off to get the securities tab.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thanks for your reply.It worked!!!
I conveyed the same to my team member.But the group name "Everyone" which applies to all is absent on his machine without which the same error "Access denied" reappears. Isn`t it possible to give write permissions to a single owner which should work.
Note: I am working with .NET 2003.
|
|
|
|
|
John Mecas wrote: Note: I am working with .NET 2003.
That doesn't matter, we're working with the file system here.
You can add any user to the folder permissions, in that dialog, including the 'Everyone' user.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
I have a gridview with a few bound fields and 2 checkboxes in template fields.
I have some filter fields which go in a placeholder on the page e.g. Disabled and Deleted checkboxes
When the user initially enters the stored procedure executes and returns the complete list.
When a user checks disabled in the filter and hits submit the page reloads executes the stored procedure and returns the items that are disabled.
My binding code is as follows:
<br />
daUserList.Fill(dtUserList)<br />
gvUserList.DataSource = dtUserList<br />
gvUserList.DataBind()<br />
<br />
Protected Sub gvUserList_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvUserList.RowDataBound<br />
<br />
Dim chkDisabled As CheckBox = CType(e.Row.FindControl("disabled"), CheckBox)<br />
Dim chkDeleted As CheckBox = CType(e.Row.FindControl("deleted"), CheckBox)<br />
<br />
Dim dataRow As DataRowView = e.Row.DataItem<br />
<br />
If dataRow IsNot Nothing Then<br />
chkDisabled.Checked = dataRow.Item("disabled")<br />
chkDeleted.Checked = dataRow.Item("deleted")<br />
End If<br />
<br />
End Sub<br />
Now when the page first loads the checkboxes are populated correctly but when I submit filter options the page reloads with the new results but with checkbox values appearing as they did in the previous view.
I've set EnableViewState="false" on the form, the gridview and the checkboxes but no joy.
Also when I debug the checkboxes are being set correctly so it must be something that is happening after the RowDataBound event that is resetting the new checkboxes with values from the checkboxes in the previous full list.
This is so frustrating, it's the last issue in my project, I've already spent a day on it and it's starting to make my project overrun!
Please, can anyone shed any light on what is happening before I start going grey?
Many Thanks,
Paul
The Website Shop
|
|
|
|
|
I don't know if this will help you at all, and bear with me as I am very much a beginner, but I am using a checkbox field in my gridview as well, however I didn't create it the way you have I used an Item Template and whacked in the checkbox on the page there, something like this
<asp:TemplateField HeaderText="Open" SortExpression="active">
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("active") %>' Enabled="False" />
</ItemTemplate>
</asp:TemplateField>
the active field that i am binding on is a simple int field in the database with either 0 for unchecked and -1 (although i believe and int will do cept 0)for checked. Dunno if that helps you out any?
Cheers
Ian Caddick
|
|
|
|
|
Hi,
Thanks that's what I have
|
|
|
|
|
Check, r u updating the data before populating (loading) again?
Regards
R.Arockiapathinathan
|
|
|
|
|
No,
I am simply reloading the page, executing the stored procedure to return a subset of the original view and then databinding those results to the gridview.
I use the gvUserList_RowDataBound event to tie up the checkboxes after the bind but even though it seems to all happen correctly in debug when my page is redisplayed it looks as though the checkboxes have picked up the values from the previous view, even though I have Enableviewstate="false" in the page directive, on the form, gridview, and controls themselves.
Any idea what is happening?
|
|
|
|
|
Hi i am using editable Grid when i select edit button on grid then after postback the row is not shown? i have to scroll the page to see the selected row? could anybody give me how to maintain the selected row to visible without scrolling the page?
thanx in advance
-- modified at 7:55 Wednesday 2nd May, 2007
Sachin M Narangale
.Net can make everything...if we mould it properly!
MCA
9860019526
|
|
|
|
|
If you are using editable grid, then i think you can't. I did the same think using template columns and manually specifying row value to be edited as query strings. Using anchor you can bring the page to the row which you are going to edit.
|
|
|
|
|
Hi,
I'm facing a problem while using tabbed windows with IE 7. I log in as a test user, say User1 in to my web application. I open another tab (new tab) in my browser (IE 7) and login to the same application as User 2. Here User1 is connected to SQL Server 2000, and User2 is connected to Oracle.
When I refresh any of the two tabs, it displays data present in the other tab. For example, both the tabs have a form, say form1 which has a datagrid. When I refresh, the datagrid in the refreshed tab displays value of the datagrid in the other IE tab.
We check the user details from the session and thats how the connection preferences are set. So when I refresh the tab, I believe the session is not stored and session of the adjacent window is taken by the refreshed window.
Is this a bug in IE 7? Does this happen with tabbed windows in Firefox?
Any thoughts on this would be greatly appreciated!
|
|
|
|
|
blumenhause wrote: Is this a bug in IE 7?
No. That is exactly how it is supposed to work. The session is unique for the instance of the browser, not for each window/tab in the instance. If it were, you would lose the session every time you navigate to a different page, making sessions totally useless.
If you want separate sessions, you have to start separate instances of the browser.
blumenhause wrote: Does this happen with tabbed windows in Firefox?
Yes. Actually as Firefox never opens separate instances of the browser, all windows in Firefox also belong to the same session.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi,
Thanks for the reply. But i'm confused, excuse me.
When I refresh the browser tab, why does it take session values from the adjacent browser tab? Does a new tab mean a separate instance of IE? Does that mean the Admin user has to open two different IE windows to connect to different Database for the same application because he needs separate session. Then whats the purpose of tabbed windows.
Could you eloborate on this a bit, I do not have lot of experience with web programming, so I'm confused now.
Regards,
Blumen
|
|
|
|