|
I want to display a message box with Ok and Cancel buttons in Asp.Net using C#. Can anyone help me in this?
Thanks in advance..
Thanks & Regards,
Radha
|
|
|
|
|
You ought to use Javascript to achieve this.
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
Use JS, confirm method for this.
|
|
|
|
|
Use , JavaScript
Alert, Confirm
|
|
|
|
|
I have tried the following but its nmot geting displayed..
Here is my code..
protected void btnSubmit_Click(object sender, EventArgs e)
{
...
CheckDate();
...
}
protected void CheckDate()
{
...
if (id > 0){ ClientScript.RegisterClientScriptBlock( typeof(Page), "Script", "alert('Selected Date have already Data.. Are you sure you want to continue for the same date? ');", true); }
else
{ ... }
}
Did i misss anything here? Can u plaese help me?
Thanks in Advance..
Thanks & Regards,
Radha
|
|
|
|
|
Radha27 wrote: if (id > 0){ ClientScript.RegisterClientScriptBlock( typeof(Page), "Script", "alert('Selected Date have already Data.. Are you sure you want to continue for the same date? ');", true); }
This won't help you. Your alert will be displayed after page processes all data. Do this in other page and show you message on the page.
|
|
|
|
|
Sorry navaneeth, can u explain me how can i do this?.. if u dont mind
Thanks in Advance
Thanks & Regards,
Radha
|
|
|
|
|
Radha27 wrote: if (id > 0){ ClientScript.RegisterClientScriptBlock( typeof(Page), "Script", "alert('Selected Date have already Data.. Are you sure you want to continue for the same date? ');", true); }
The above code won't work because, JS will emitted to the response and displayed to the page after all processing done by ASP.NET. It won't wait until you press the Ok button in the alert. So this method is no use. Instead of this, you can redirect to another page where a message will be displayed like "Selected date have already data. Are you sure to continue". Put two buttons, "Continue" and "Cancel". Inside "Continue" button write your logic for continuing the operation.
Hope it clear now.
|
|
|
|
|
Ok, Thank u, I got it.. but is there any other possibility to solve this?
Thanks & Regards,
Radha
|
|
|
|
|
You can display this in same page also. Put those two buttons inside a panel which is set as hidden when page loads. When your condition satisfies, make this panel visible which will show message and buttons. This help you to avoid transferring data from this page to the message page.
|
|
|
|
|
Thank You, I will try.
Thanks & Regards,
Radha
|
|
|
|
|
hi all ,
I want have one confirmation box with Yes and No button with default focus is on No.
1.I have tried with Windows.confirm(), but the focus cannot be changed default to NO it seems.
2. I cannot use MessageBox because it is c# website and we use publish code in which messagebox dont work.
I need this very very urgently plssss help
Thanks in advance
Sampad
|
|
|
|
|
Hi friends,
I there anyway to stop the popout calendae from closing when i click next/prev month? Following is my code(taken from ASP.NET 2.0 unleashed):
==========================================================================
]]>
<!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 calEventDate_SelectionChanged(object sender, EventArgs e)
{
txtEventDate.Text = calEventDate.SelectedDate.ToString("d");
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
lblResult.Text = "You picked: " + txtEventDate.Text;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<script type="text/javascript">
function displayCalendar()
{
var datePicker = document.getElementById('datePicker');
datePicker.style.display = 'block';
}
</script>
<style type="text/css">
#datePicker
{
display:none;
position:absolute;
border:solid 2px black;
background-color:white;
}
.content
{
width:400px;
background-color:white;
margin:auto;
padding:10px;
}
html
{
background-color:silver;
}
</style>
<title>Calendar with JavaScript</title>
</head>
<body>
<form id="form1" runat="server">
<div class="content">
<asp:Label
id="lblEventDate"
Text="Event Date:"
AssociatedControlID="txtEventDate"
Runat="server" />
<asp:TextBox
id="txtEventDate"
Runat="server" />
<img src="Calendar.gif" onclick="displayCalendar()" id="IMG1" />
<div id="datePicker">
<asp:Calendar
id="calEventDate"
OnSelectionChanged="calEventDate_SelectionChanged"
Runat="server" />
</div>
<br />
<asp:Button
id="btnSubmit"
Text="Submit"
Runat="server" OnClick="btnSubmit_Click" />
<hr />
<asp:Label
id="lblResult"
Runat="server" />
</div>
</form>
</body>
</html>
==========================================================================
Thanks
lene
|
|
|
|
|
Not sure if you've Already resolved your problem but this is what I did to my calendar. Basically, you need to catch another event in your calendar: OnVisibleMonthChanged
Calendar.aspx
<br />
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Calendar.aspx.cs" Inherits="Calendar" %><br />
<br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br />
<html xmlns="http://www.w3.org/1999/xhtml"><br />
<head runat="server"><br />
<title></title><br />
</head><br />
<body><br />
<form id="form1" method="post" runat="server"><br />
<asp:TextBox ID="txtDate" runat="server" Width="220px"></asp:TextBox><br />
<asp:Button ID="btnCalendar" runat="server" OnClick="btnCalendar_Click" Text="...." /><br />
<br /><br />
<asp:Calendar ID="cdrDate" runat="server" SelectionMode="Day" BorderWidth="1px" BackColor="White"<br />
Width="220px" DayNameFormat="FirstLetter" ForeColor="Purple" Height="200px" Font-Size="8pt"<br />
Font-Names="Verdana" BorderColor="Black" ShowGridLines="True" OnVisibleMonthChanged="cdrDate_MonthChanged"<br />
OnSelectionChanged="cdrDate_SelectionChanged"><br />
<TodayDayStyle ForeColor="Black" BackColor="Beige"></TodayDayStyle><br />
<WeekendDayStyle BackColor="LightGoldenrodYellow"></WeekendDayStyle><br />
<SelectorStyle BackColor="Black"></SelectorStyle><br />
<NextPrevStyle Font-Size="9pt" ForeColor="White"></NextPrevStyle><br />
<DayHeaderStyle Height="1px" BackColor="LightGoldenrodYellow"></DayHeaderStyle><br />
<SelectedDayStyle Font-Bold="True" BackColor="Gray"></SelectedDayStyle><br />
<TitleStyle Font-Size="9pt" Font-Bold="True" ForeColor="White" BackColor="Gray"><br />
</TitleStyle><br />
<OtherMonthDayStyle ForeColor="Gray"></OtherMonthDayStyle><br />
</asp:Calendar><br />
</form><br />
</body><br />
</html><br />
<br />
<br />
Calendar.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Calendar : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
txtDate.Enabled = false;
cdrDate.Visible = false;
}
protected void btnCalendar_Click(object sender, EventArgs e)
{
if (txtDate.Text.Trim() != "")
cdrDate.SelectedDate = Convert.ToDateTime(txtDate.Text);
cdrDate.Visible = true;
}
public void cdrDate_MonthChanged(object sender, MonthChangedEventArgs e)
{
cdrDate.Visible = true;
}
protected void cdrDate_SelectionChanged(object sender, EventArgs e)
{
txtDate.Text = cdrDate.SelectedDate.ToString("yyyy-MM-dd");
cdrDate.Visible = false;
}
}
Hope that help
|
|
|
|
|
Hi i try to send one mail with attachment...,
But its sending except c drive file attachments...,
Y its not accepting c drive files
plz any one help me,
This is my code:
Sub mailsend()
Dim objMail As New MailMessage
Dim objAttach As MailAttachment
Dim objConn As SmtpMail
Dim postedFile = fileUpload.PostedFile
Dim strPath As String = ""
Try
strPath = Path.GetFullPath(postedFile.FileName)
Catch
End Try
objMail.From = ddlAprroveId.SelectedItem.Text
objMail.To = ddlAprroveId.SelectedItem.Text
objMail.Subject = "Travel Expense Statement From " & ddlTrEmpId.SelectedItem.Text
objMail.Body = "At " + DateTime.Now + "
" & _
". Plz Find the attachment in this mail " & _
"send by " & ddlTrEmpId.SelectedItem.Text & "." & vbCrLf & vbCrLf & _
"---------------------------------------" & vbCrLf & vbCrLf & _
txtTotalExp.Text & vbCrLf
objMail.Priority = MailPriority.High
Try
objAttach = New MailAttachment(strPath)
objMail.Attachments.Add(objAttach)
Catch
End Try
objConn.Send(objMail)
End Sub
Thanks & Regards,
Mageshh,
please don't forget to vote on the post
|
|
|
|
|
What is the error you are getting?
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
i am not getting any error its not attaching the file,
while send,
Thanks & Regards,
Mageshh,
please don't forget to vote on the post
|
|
|
|
|
You have use exception escaping with a blank catch statement. Remove your try-catch and you will get exception.
|
|
|
|
|
Hi Friends,
Forms Authentication in .NET framework is very useful utility. But I have a feeling that only ASPNETDB database structure would not help me.
Is there a way to use Forms Authentication with my own database?
|
|
|
|
|
Here[^] is a similar discussion.
|
|
|
|
|
Hi Guys
Need help here. I am using asp.net in 2005 with IIS 6.0. During my testing phase i have no problem generating Excel from data. However when the data grow, everytime i generate a large amount of data , the system prompt error or hang there
Any ideas on how to improve the application or resolve the issue?
This is the error msg:
Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.
Thanks A Million Guys
You guys are life saviour!!!!!!
KaKaShi HaTaKe
|
|
|
|
|
I am a new asp.net developer. I am trying to come up with a game which is to be opened in the browser and the client has to play it.
My problem is to move an image on the web form. I had the timer control configured but i am unable to get the location of image to move on the timer tick.
When i have done it in Window forms in VB i have a picture box and i have the location attribute for it which i have used to move.
But in ASP.NET web forms i dont have picture box. Could you guys help me out to get to a solution.
Is there a possibility to write user control of picture box or take it from VB in asp.net
I would really appreciate any advise on how to tackle the problem
|
|
|
|
|
|
Hello,
how can i set default button of a ASP.NET webpage with C# code?
We set default button of a windows application Form as
this.AcceptButton = btnShow;
i want like this. but for a webpage.
Please reply..
THANK YOU
Dipak
|
|
|
|
|
In 2.0 and up...
Drop an asp:panel control on your page.
Each panel control has a Default Button Property.
I didn't get any requirements for the signature
|
|
|
|