|
Oops sorry. Can you not simply use the code-behind to solve this issue?
Because your clicking on a server control the page is reloaded back to its orginal state. If you want to change the text of the button after changing the label control using JavaScript then you will need to change the second button using JavaScript also.
|
|
|
|
|
No. I am working on an application that utilizes a scheduling control. This control has a client-side click event that I must use. When I click on the control it must set a property wich in turn must be used when a button on the page is clicked. My solution to this was to set a label's text property but that doesn't seem to work, as you have seen in my code. Maybe you can help me out. Thanks anyways.
|
|
|
|
|
Only other way I can think of is to use a hidden field.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Test</title>
<script type="text/javascript">
function Hello() {
var value = "bye";
document.getElementById("<%=Button2.ClientID %>").disabled = false;
document.getElementById("<%=Label1.ClientID %>").innerText = value;
document.getElementById("<%=hdnValue.ClientID %>").value = value;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="Button1" type="button" value="Button1" onclick="Hello()" /><br />
<asp:Button ID="Button2" runat="server" Enabled="False" Text="Button2" />
<br />
<asp:Label runat="server" ID="Label1" Text="hello" />
<asp:HiddenField ID="hdnValue" runat="server" />
</div>
</form>
</body>
</html>
void Page_Init(object sender, EventArgs e)
{
Button2.Click += new EventHandler(Button2_Click);
}
protected void Page_Load(object sender, EventArgs e)
{
}
void Button2_Click(object sender, EventArgs e)
{
Button button = (Button)sender;
button.Text = hdnValue.Value;
}
|
|
|
|
|
Thank you very much! It works!
|
|
|
|
|
When I click button 1, button 2 must be enabled and the label's text must change from "hello" to "bye". This must be done clientside through Javascript. How must I change the following code to get this to work? When I click button 1 the label's text changes but immediately reverts back to it's original value.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Test</title>
<script type="text/javascript">
function Hello() {
document.getElementById('Button2').disabled = false;
document.getElementById('Label1').innerText = "bye";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="Hello()"/>
<br />
<asp:Button ID="Button2" runat="server" Enabled="False" Text="Button" />
<br />
<asp:Label runat="server" ID="Label1" Text="hello"></asp:Label>
</div>
</form>
</body>
</html>
|
|
|
|
|
When you click the button the client-side script is being executed properly, however, it also causes a post-back which resets the page. If all you need to do execute client-side script with no post-back then change the asp:button controls to simple html elements <input type=button>
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Or just put a
return false; in the Hello function.
That should also work.
..Go Green..
|
|
|
|
|
Only if he includes the "return.." part in the OnClientClick
also. Like:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Test</title>
<script type="text/javascript">
function Hello() {
document.getElementById('Button2').disabled = false;
document.getElementById('Label1').innerText = "bye";
return false;
} </script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return Hello()" />
<br />
<asp:Button ID="Button2" runat="server" Enabled="False" Text="Button" />
<br />
<asp:Label runat="server" ID="Label1" Text="hello"></asp:Label>
</div>
</form>
</body>
</html>
|
|
|
|
|
Could you perhaps explain the purpose of these return statements?
|
|
|
|
|
Returning a value in a javascript click event handler tells the browser whether or not to continue normal processing of that click. For a submit button, returning false tells it to stop processing a not to actually submit the form. Returning true allows it to continue submitting the form normally. For a hyperlink returning true would allow the browser to navigate to the URL and returning false would leave the user on the curernt page.
|
|
|
|
|
return statement is to avoid PostBack.
"When I click button 1 the label's text changes but immediately reverts back to it's original value."
this is because of PostBack
Raju.M
|
|
|
|
|
Yes. And that's what I said.
His Hello() function is called on OnClientClick. I missed the return in OnClientClick part.
I am sorry I didn't explain it.
..Go Green..
|
|
|
|
|
Hi..
I am revisiting codeproject after couple of days due to my old question.
I have done some coding in session_end in global.asx and want to execute this event , if someone closes the browser window.
I just want to have alternative to authentication.
thanks,
By:
Hemant Thaker
modified on Friday, June 25, 2010 8:17 AM
|
|
|
|
|
I believe someone posted an article or tip/trick regarding this a few days ago though can't find it now. Try searching through recent articles.
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
nils illegitimus carborundum
me, me, me
|
|
|
|
|
Hi, I have a generic list of objects returned and I want to store it in a datatable in viewstate as I have to do some in memory operations on the list (edit,update,delete)
How to go about this task ?
Mike.
|
|
|
|
|
|
Hi I have a gridview which has some records (recordID is being fetched from database)
I load the results in datatable which has columns like
--------------------------------------
RecordID | EmployeeID | Name | Address
--------------------------------------
1 4 John xyz
2 5 Smith xyz
Now user can edit the records with a checkbox list (problem is that he can reselect the existing checked items again, so the recordID is null for reselected items, I set it to zero to distinguish all new records)
So the new datatable becomes
--------------------------------------
RecordID | EmployeeID | Name | Address
--------------------------------------
0 4 John xyz (reselected rows with 0 id)
0 5 Smith xyz (reselected rows with 0 id)
0 8 Evans xxx (new record)
Now I am on form update button, I am trying to figure out how to find which records to insert and how to find records to do nothing with ? The reselected records already existing in database are creating problem for me.
Mike.
|
|
|
|
|
Hi,
I have designed ASP.NET C# 3.5 (MySQL) website and it is hosted on shared web server.
I have to send email to site users. I have written the all required code, I am sending mail from "info@mysitename.com" to yahoo or gmail but having the following exception.
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Net.Mail.SmtpPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Line 41: objEmail.Priority = MailPriority.Normal;
Line 42:
Line 43: SmtpClient smtpClient = new SmtpClient(smtpServer, Convert.ToInt32(port));
Line 44: System.Net.NetworkCredential basicAuthenticationInfo = new System.Net.NetworkCredential(fromAddress, pwd);
Line 45:
Thanks
|
|
|
|
|
Dot-Net-Dev wrote: ine 43: SmtpClient smtpClient = new SmtpClient(smtpServer, Convert.ToInt32(port)); Line 44:
Everything is pretty self explanatory. The port that you are trying to use to send emails is blocked by your IT team. You need to talk to them and get it unblocked.
Further make sure you have configured SMTP configuration in Web.Config:
<system.net>
<mailSettings>
<smtp from="abc@somedomain.com">
<network host="somesmtpserver" port="25" userName="name" password="pass" defaultCredentials="true" />
</smtp>
</mailSettings>
</system.net>
If needed, have a look at this Microsoft Video tutorial: Use ASP.NET to Send Email from a Web Site [^]
|
|
|
|
|
i read a social.msdn[^] thread, some problem in upload image in IE7, is this true?
Raju.M
|
|
|
|
|
makhaai wrote: some problem in upload image in IE7, is this true
No! We have it and working perfectly fine.
If you read the response to the query asked, there might be path issue with the person reported.
|
|
|
|
|
i dont think the problem arise because of path, its working with IE6. and i aslo seen some threads but now one answer that question. but our thread have update please social.msdn[^]
Raju.M
|
|
|
|
|
I tried this
byte[] imageContent = (byte[])(ds2.Tables[0].Rows[0]["Signature_File"]);
MemoryStream ms1 = new MemoryStream(imageContent);
//IDataObject data = new IDataObject();
Bitmap bmp;
Image returnimage = Image.FromStream(ms1).ToString();
I am getting Parameter is not valid error
Please help
Thanks,
Raghvendra Panda
|
|
|
|
|
I m creating a website in ASP.NET using C#.through the web I want to monitor the activities of all the folders present at "C:\Inetpub\ftproot\san".User can work on any type of files and not only text files.Since we have given 1GB space (lets say) to each user, so user can do anything to utilize this space.
Now I want to monitor the activites that the user will do in his folder like creating new file, deleting an existing file or editing a file.I want to monitor user's activities because i have to keep track of the space given to the user so tht i can restrict the user to use 1GB space only and not more than that. is there any class that i can use other than FileSystemWatcher as it works only in console applications and not in webapplications?? any help would be highly apperciated.. Many thanks
|
|
|
|
|
My suggestion: create a Windows Service that runs continuously (using FileSystemWatcher), and records the activity to a database that your ASP can read/display from.
|
|
|
|