|
Hi,
Am getting this error in the Button click event after entering the credentials, not getting this error each time i click. I searched for this in
all the msdn, blogs, asp.net forums etc... They r saying to register the event. I did the same by writing the following code
protected override void Render(HtmlTextWriter writer)
{
Page.ClientScript.RegisterForEventValidation(Login1.UniqueID);
base.Render(writer);
}
But there is no use still am getting the same error even after registering the event too. Can anyone help me how to overcome this problem.
Thanks in Advance!
|
|
|
|
|
In your web.config on the page tag set EnableEventValidation=False
|
|
|
|
|
Thanks for reply!
This is the security issue right. I cant do that.
Can I Have Other solution for this?
Thanks!
|
|
|
|
|
help me!
when i use Response.Redirect how do i determine the target ?
i want that my page open in the main frame in my page?
when i use the link we can the target by target="main"
but in this case ...?
what can i do?
ava_h
|
|
|
|
|
You can't determine the target. The target was determined already when the request was sent to the server, so it's too late to change the target.
You either have to change the target before the request is sent from the browser, or you have to send a response that is a page that contains Javascript that will make the browser send a new request with the target you want.
---
b { font-weight: normal; }
|
|
|
|
|
I have recieved no answer from my previous query but I do have more information so hopefully I someone may have some more information for me. (For a quick reminder I am creating an ASP.NET control to upload n number of files and as part of that I am using Javascript to dynamically generate file inputs through the DOM)
When uploading a file through ASP.NET the encoding type of the form must be "multipart/form-data" which I already knew, however, it must be the HtmlForm for the page that is set and not just any form. (http://msdn2.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlform.aspx, and http://msdn2.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlinputfile.aspx)
A simple loop through Page.Controls reveals the HtmlControl for the page if there is one. (Surprise there is no method to return it! so you must roll your own) With this set I am still unable to upload files!
Now here is where it gets really interesting: If I add <input type="file" id="thisIsATest" runat="server"/> somewhere in my user control everything works even though I am not using the thisIsATest element for the upload. I can't find any meaningful difference in the HTML source between the two.
Any ideas?
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: A simple loop through Page.Controls reveals the HtmlControl for the page if there is one. (Surprise there is no method to return it! so you must roll your own) With this set I am still unable to upload files!
You can use the HttpRequest.Files Property [^] to access the uploaded file collection.
Ennis Ray Lynch, Jr. wrote: I can't find any meaningful difference in the HTML source between the two.
The difference is that the HtmlInputFile marked with runat="server" will set the Enctype = "multipart/form-data" for the form element if this property is empty.
|
|
|
|
|
Heh, the problem is the HttpRequest.Files.Property does not get populated when you generate your own html code using Javascript and DOM even if you set the enctype.
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: HttpRequest.Files.Property does not get populated when you generate your own html code using Javascript and DOM even if you set the enctype.
Yes, it does.
|
|
|
|
|
I may seem like a moron but I am not, I have actually been working on this for quite a while. When I generate input type of file using javascript they are not uploaded on the post even when the encType is properly set unless I have placed one using the designer.
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
|
|
|
|
|
Below is a quick example:
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void btnUpload_Click(object sender, EventArgs e)
{
Response.Write(string.Format("Files uploaded: {0} <br/>", Request.Files.Count));
HttpFileCollection files = Request.Files;
for(int index=0; index<files.Count; index++)
{
Response.Write(string.Format("Filename: {0} size: {1} <br/>", files[index].FileName, files[index].ContentLength));
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Dynamic upload</title>
<script type="text/javascript">
var iCount = 0;
function AddInputFile()
{
iCount++;
var inputFile = document.createElement("<input type='file' id='file" + iCount +"' name='file"+ iCount +"' />");
var br = document.createElement("<br/>");
var container = document.getElementById("divInputFile");
container.appendChild(inputFile);
container.appendChild(br);
}
</script>
</head>
<body>
<form id="form1" runat="server" enctype="multipart/form-data">
<div id="divInputFile">
</div>
<button on_click="AddInputFile();">Add New Upload</button>
<asp:Button runat="server" ID="btnUpload" Text="Upload" On_Click="btnUpload_Click" />
</form>
</body>
</html>
|
|
|
|
|
That is nearly identical to what I have. Yet for some reason it does not work. The only way I can get it to work is to type out
<br />
<input type="file" runat="server" id = "blah" /><br />
Somewhere in the html in the aspx page. If that isn't there the upload doesn't work! That is why I am so troubled, it is supposed to work.
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
|
|
|
|
|
Which .NET version did you write your code in? I am writing in 1.1 at work which is were I am having the problem.
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: Which .NET version did you write your code in? I am writing in 1.1 at work which is were I am having the problem.
I'm doing the version 2.0 (v2.0.50727), I'll try in the version 1.1 then.
|
|
|
|
|
It works just fine with the v1.1.4322 version.
|
|
|
|
|
I will just try backing out until it works (hopefully). Thanks for checking for me, btw. I think it might be related to the form tag then.
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
|
|
|
|
|
Your html head is marked as runat server, does that mean AddInputFile is running at the server?
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
|
|
|
|
|
ASP.NET will autogenerate a name element for all controls created on the server-side and the HTML spec, http://www.w3.org/TR/html4/interact/forms.html#successful-controls[^], states the name is required for Successful controls and only successful controls are required to be posted back.
To make it weird it seems browser agents still group by id for a post so input elements with the same id are submitted if at least one has a name? Neat. So, if you want to dynamically generate input elements in client-side java script you must include the name attribute in the input element tag!
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
|
|
|
|
|
Hi All,
We currently use our own authentication scheme for our ASP.Net applications. However, we now investigation using Forms Authentication so we can take advantage of some the personalization and web parts functionality in .Net 2.0.
Is it possible, on a single web server, to have a single login virtual directory that contains the login page, but require each user to authenticate to each application. Example
| web server root
|
| - Application1
|
| - default.aspx
|
| - Application2
|
| - default.aspx
|
| - Login
|
| - login.aspx
So, basically, is this scenario possible using forms authentication. I've been trying and seem to get in a loop. I access application1, it redirects to the login page, authenticates OK, redirects back to application1, but it takes me back to the login page.
Any help would be greatly appreciated.
Regards,
Robert
-- modified at 18:26 Wednesday 18th October, 2006
|
|
|
|
|
The problem here IMO is that the Login.aspx web page is located outside the boundary of the web application such as application1, so the authentication ticket generated does not have meaning to the application1 and as a result of that the application1 refuses to access its web page. What you might need to do is to configure so that the authentication cookies can be used across the application boundary, for more details you can see Forms Authentication Across Applications[^]
Also, you require the authentication for each application, not for all, so the name of the authentication cookie should be dynamically set in the Login page depending on which application is currently accessed.
|
|
|
|
|
Hi,
Still haven't been able to get it to work... I've tried changing the cookie name in code dynamically but the properties I've trying to use are read-only. Which property should I be setting in code?
Here is the Login virtual directory web.config:
<authentication mode="Forms"><br />
<forms loginUrl="/FALogin/Login.aspx" name="Login" protection="All" path="/" <br />
timeout="30" enableCrossAppRedirects="true"><br />
</forms><br />
</authentication><br />
<authorization><br />
<allow users="?" /><br />
</authorization><br />
<machineKey validationKey="C50B3945949462D0E8DB8CB5CDA1742572A487D9401E3400267682B202B746511891C1BAF47F8D25C07F6C39A104696DB51F17C529AD3CABE" <br />
decryptionKey="8A9BE8FD67AF6979E7D20198CFEA50DD3D3799C77AF2B72F" <br />
validation="SHA1" />
Here is the Application 1 virtual directory web.config:
<authentication mode="Forms"><br />
<forms loginUrl="/FALogin/Login.aspx" name="Application1" protection="All" path="/" <br />
timeout="30" enableCrossAppRedirects="true"><br />
</forms><br />
</authentication><br />
<authorization><br />
<allow users="?" /><br />
</authorization><br />
<machineKey validationKey="C50B3945949462D0E8DB8CB5CDA1742572A487D9401E3400267682B202B746511891C1BAF47F8D25C07F6C39A104696DB51F17C529AD3CABE" <br />
decryptionKey="8A9BE8FD67AF6979E7D20198CFEA50DD3D3799C77AF2B72F" <br />
validation="SHA1" />
Thanks.
Robert
|
|
|
|
|
+ The FormsAuthentication.FormsCookieName Property is read-only , so you cannot set this property in code. In this case, you can manage to add the authentication ticket on your own, the sample code can be found from here[^].
+ So basically, you'll have a web.config file for each application, and one web.config with the same settings at root. At the first step, you can simply set the name property of the forms entry in the web.config file both at root and at the application level identically, and see how it works. Then to make it work for multiple applications with a single login web page at the web server root, you need to manage to add the cookie on your own in code with the cookie name depending on the application being accessed by the user.
|
|
|
|
|
how i can run an exe file on asp.net c# ?
|
|
|
|
|
You can't. You CAN, but it will run on the server, not the client. You have to get them to down load the file and run it themselves, and they probably won't be able to do it without unblocking it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi,
This may be a very common task that many websites carry out, but I dont seem to find a proper solution for the same. Pls help me out
I have a webpage with a datagrid and stuff and 3 buttons. On the click of 2 out of those 3 buttons, I know that the processing time taken at backend is longer, so I need to change the mouse pointer to Hourglass so that none of the buttons are clickable, whereas when the processing is over and screen is updated with new data, I need to show default mouse pointer to the user.
The basic problem what I see here, is that, Because the Client side page rendering doesn't start before server side code is run through, how do you set 2 different cursors at the start of event and then at the end of that event.
Pls Guide me.. I am totally confused, whether this is even possible.
Thanks.. Waiting for ur scholarly reply.
Omkar
|
|
|
|