|
Hi!
I just started working a bit with web the other day. I was just playing around, making an aspx-page with a asp:DropDownList and a asp:Button. I populated the dropdownlist with a couple of posts. Based on current post in dropdownlist I wanted different things to happen when I clicked the button. Only problem is, selectedindex on dropdownlist is always -1. The page is somehow reset even before I get to register what actually happened on it. What am I doing wrong?
|
|
|
|
|
Two issues
1 - you should have asked in teh ASP.NET forum
2 - odds are high you're setting the data source of the control in your page load every time. This resets the selected index. Use IsPOstback to do it once, and also try to do binding in the prerender event
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Sorry I asked in the wrong forum Regarding issue 2 I do have this if (!IsPostBack) in load-event before I populate the dropdownlist. Ill try that thingie with prebinder event, thanks!
|
|
|
|
|
Any thoughts?
I'd like to set up a tiny file sharing site (work documents etc) with uploading and file listing. However it needs to have some access control so that only permissioned users can upload/download. Is there a decent method (example?) of doing this without having to rely on web server folder permissions?
Thx++
Jerry
|
|
|
|
|
You could use Subversion, which not only gives you a reasonably fine-grained permissions system if you don't like Apache's, but also gives you versioning...
But who is the king of all of these folks?
|
|
|
|
|
Not the right sized solution. Need to be able to put and get password protected files from a vanilla web hosting service.
|
|
|
|
|
Hiya,
Are you using ASP.NET? Or some kind of CGI (Common Gateway Interface) app?
Lloyd J. Atkinson
"Logic will get you from A to B, but imagination will take you everywhere" -ALbert Einstein
|
|
|
|
|
Hi Lloyd
Yes - any ideas?
Thx
|
|
|
|
|
Hiya,
In ASP.NET you could always try the Login component??
Lloyd J. Atkinson
"Logic will get you from A to B, but imagination will take you everywhere" -ALbert Einstein
|
|
|
|
|
function callreg()
{
alert("hello");
var shl = new ActiveXObject("WScript.Shell");
shl.RegWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3\\2104", 0, "REG_DWORD");
}
This script is correctly working in local system. When i access this with remote system, it shows an error automation server cannot create object. Can any one help me to solve it???
Thanks in advance
Sutheesh
|
|
|
|
|
Nice try, buddy. That crap doesn't work on the web, and for good reason.
But who is the king of all of these folks?
|
|
|
|
|
What's this??????????
"Legacy code" often differs from its suggested alternative by actually working and scaling.
—Bjarne Stroustrup
|
|
|
|
|
HI ALL,
Now I am facing a problem with webservice callback.We called a webmethod asynchronously from a webpage.Then the page will be rendered from the server to the client,but the result of the called method may be reaches the webservice after rendering the site.So the webservice become not able to send the result to webform.My question is how to inform the webform asynchronously without polling for its completion and too much delay?
Plz Help................
|
|
|
|
|
The whole point of asynchronous calls is that you get notified when they're done. If you're gonna return before it's done, then you've left yourself no choice but to poll in some fashion.
I suggest you go for a long walk, and ponder the motivations behind building asynchronous HTTP request support into browsers...
But who is the king of all of these folks?
|
|
|
|
|
Hi,
I use repeater to list data from database. Once the repeater is populated, I want to get the column width for each column in the repeater table in javascript function. I am trying to do in table's onresize event. The code is shown as below:
...
<script type="text/javaScript">
function getColumnWidth()
{
alert("List the width of each table column");
//get the width of column and do something
}
</script>
<table id="tbTableBody" onresize="getColumnWidth()" >
<asp:Repeater id="rptAccounts" runat="server" >
<ItemTemplate >
<tr>
<td>Field1 value </td>
<td>Field2 value </td>
<td>Field3 value </td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
...
However, onresize event doesn't fire at all. If I use onmousemove, instead of onresize, the javascript function getColumnWidth() will get executed. But if the page is loaded, but the user doesn't move the mouse, then the javascript function will not be able to executed.
Does anyone know what I need to do to make it work?
Thanks in advance!
|
|
|
|
|
Hi,
How do I set a confirm box's title, in Fire Fox it just says [JavaScript Application]. It looks horrible.
I hope to hear from someone soon.
Brendan
|
|
|
|
|
.NET Enthusiast wrote: It looks horrible.
Oh no, I don't how I will get any sleep tonight!
led mike
|
|
|
|
|
ha lols.
-----------------------------------------------------------
Completion Deadline: two days before the day after tomorrow
|
|
|
|
|
You can't. It's a security feature of JavaScript to stop web pages pretending to be something else.
|
|
|
|
|
That's what confirm boxes in Firefox look like. No one is forcing you to use them, but if you do then you play by the rules.
Sorry - it could have been better, but a bunch of assholes with no consideration for their users or others ruined it for everyone. See also the "Automation" question above...
But who is the king of all of these folks?
|
|
|
|
|
Hi,
How do I fire a specific event when clicking on a buttin?
I have code in:
window.onbeforeunload = function()
{
...my code
}
I need to trigger/fire this event when the button is clicked.
Thanks
Brendan
|
|
|
|
|
Add an onclick="functionName();" to your input tag.
|
|
|
|
|
Hi,
Below is the code of my body tag. The checkForChange method is called twice, why is this? I only need it to be called once. What it needs to do is to check if a textbox was changed, if so then it must display a message, but the message needs to be displayed if the user wants to go to another page if data was changed.
<body onbeforeunload="checkForChange();" >
<input type="text" onchange="isDirty = true;" />
<input type="submit" name="btnCancel" value="Cancel" id="btnCancel" onclick="return checkForChange();" />
<br /><br /><br /><br />
<a href="Link.htm">LinkLinkLinkLinkLinkLinkLinkLink</a>
<script language="javascript" type="text/javascript">
var isDirty = false;
function checkForChange()
{
if (isDirty)
return confirm('Changes have been made.');
else
return true;
}
</script>
</body>
If the user clicks cancel, it should stay on the current page, but if it clicks ok, then it should move to the next page. Currently the massge boz is displayed twice, and it doesn't matter what is clicked it still goes to the next page (on the link that was clicked).
Please can someone help.
Thanks
Brendan
<div class="ForumMod">modified on Wednesday, February 13, 2008 5:35 AM</div>
|
|
|
|
|
The code below works fine in IE 6.0. Perhaps it can solve your problem.
<head>
<script type="text/javascript">
var isDirty = false;
function checkForChange() {
if (isDirty) {
alert("Changes have been made.");
}
}
function moveToNext() {
if (isDirty) {
if(confirm('Move to next page...')) {
var myLink = document.getElementById('myLink');
myLink.href='Link.htm';
myLink.click();
}
}
}
</script>
</head>
<body>
<input type="text" onchange="isDirty=true;" />
<input type="submit" name="btnCancel" value="Cancel" id="btnCancel" onclick="javascript:checkForChange();"/>
<br /><br /><br /><br />
<a id="myLink" href="javascript:moveToNext();">LinkLinkLinkLinkLinkLinkLinkLink</a>
</body>
|
|
|
|
|
Hi All
I am trying to allow one to three (3) files to be uploaded to a server, then send an email to the recipient for verification.
The files upload correctly and the email is sent, however it sends three emails for the one upload process.
What do I need to change in the code so that I only send one email for the complete process?
Any help would be appreciated.
Regards
Robert Caya
Here is the code for the process ...
default.aspx
]]>
<title>Document Upload and Email Verification
Document Upload and Email Form Sender
<asp:fileupload id="FileUpload1" cssclass="textSmall" runat="server" width="250px">
<asp:fileupload id="FileUpload2" cssclass="textSmall" runat="server" width="250px">
<asp:fileupload id="FileUpload3" cssclass="textSmall" runat="server" width="250px">
|
|
Your Name: | <asp:textbox id="txtName" cssclass="textSmall" width="241" runat="server"> | Your Email Address: | <asp:textbox id="txtEmail" cssclass="textSmall" width="241" runat="server"> | Your Comments: | <asp:textbox id="txtMessage" width="100%" runat="server" height="99" textmode="MultiLine" maxlength="400"> | | |
<asp:button id="Button1" cssclass="textSmall" runat="server" text="Send Now" onclick="Button1_Click">
<asp:button id="Button2" cssclass="textSmall" runat="server" text="Reset" onclick="Button2_Click">
| | <asp:label id="lblStatus" runat="server" enableviewstate="False"> | |
<asp:label id="Label1" cssclass="textSmall" runat="server">
|
|
<asp:requiredfieldvalidator id="RequiredFieldValidator1" runat="server">
ErrorMessage="You must enter your name." ControlToValidate="txtName">
<asp:requiredfieldvalidator id="RequiredFieldValidator2" runat="server">
ControlToValidate="txtEmail" ErrorMessage="You must enter your email address">
<asp:regularexpressionvalidator id="RegularExpressionValidator1" runat="server">
ControlToValidate="txtEmail" ErrorMessage="Please correct the format of your email to: example "someone@somewhere.com"."
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">
default.aspx.cs
using System;
using System.IO;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net.Mail;
public partial class _mailUpload : System.Web.UI.Page
{
protected void Button1_Click(object sender, EventArgs e)
{
string filepath = "d:\\Uploads";
HttpFileCollection uploadedFiles = Request.Files;
SmtpClient smtpClient = new SmtpClient();
MailMessage message = new MailMessage();
MailAddress fromAddress = new MailAddress(txtEmail.Text, txtName.Text);
for (int i = 0; i < uploadedFiles.Count; i++)
{
HttpPostedFile userPostedFile = uploadedFiles[i];
try
{
if (userPostedFile.ContentLength > 0)
{
Label1.Text += "File #" + (i + 1) + " ";
Label1.Text += "File Name: " + userPostedFile.FileName + " ";
Label1.Text += "File Size: " + userPostedFile.ContentLength + "kb";
userPostedFile.SaveAs(filepath + "\\" +
System.IO.Path.GetFileName(userPostedFile.FileName));
}
// Default is localhost or you can specify a host name or ipaddress of the email server
smtpClient.Host = "localhost";
//Default port is 25
smtpClient.Port = 25;
//From address will be given as a MailAddress Object
message.From = fromAddress;
// To address collection of MailAddress
message.To.Add("rob@mydomain.com");
message.Subject = "Client File Upload System";
// CC and BCC optional
// MailAddressCollection class is used to send the email to various users
// You can specify Address as new MailAddress("admin1@yoursite.com")
//message.CC.Add("admin1@yoursite.com");
//message.CC.Add("admin2@yoursite.com");
// You can specify Address directly as string
//message.Bcc.Add(new MailAddress("admin3@yoursite.com"));
//message.Bcc.Add(new MailAddress("admin4@yoursite.com"));
//Body can be Html or text format
//Specify true if it is html message
message.IsBodyHtml = true;
// Message body content
message.Body = txtMessage.Text + "
The following files have been uploaded to the server.
" + Label1.Text;
// Send SMTP mail
smtpClient.Send(message);
lblStatus.Text = "Your email has been successfully sent.
The following files have been uploaded to the server.";
}
catch (Exception Ex)
{
Label1.Text += "There was an error sending your files ... " + Ex.Message;
lblStatus.Text += "Your email failed to send correctly ... " + Ex.Message;
}
}
}
#region "Reset"
protected void Button2_Click(object sender, EventArgs e)
{
txtName.Text = "";
txtEmail.Text = "";
txtMessage.Text = "";
Label1.Text = "";
}
#endregion
}
|
|
|
|