|
how to display message in Message box in asp.net with c#
|
|
|
|
|
Use the javascript alert method.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Here is a simple procedure that dynamically builds a Javascript Alert Message and writes it to the client using Response.Write . you can use this procedure by adding it to the code-Behind . This would be useful when you do a server-side validation and want to prompt a alert message to the user.
protected void MessageBox(string strMsg)
{
string strScript = "<script language=JavaScript>";
strScript += "alert('" + strMsg + "');";
strScript += "</script>";
Response.Write(strScript);
}
- Regards - J O N
A good thing is a bad thing if it keeps you from the best thing. - Dr. Adrian Rogers
|
|
|
|
|
Page.ClientScript.RegisterStartupScript(Page.GetType(), "@msg", "alert('Message that u want to display...');", true);
Jintal Patel
|
|
|
|
|
In order to save bandwidth, I set the viewstate to serverside using the method discribed here:http://msdn2.microsoft.com/en-us/library/system.web.ui.sessionpagestatepersister.aspx[^]
It all seems to work well, pagesize has shinked up to 60-70%. On my local server everthing works as it should. However, when I put it on the live server, problems arise. When I am using dynamic content, and I wait too long (about 10 seconds), the viewstate gets lost somehow, and an error occurs. The error message I get is: System.NullReferenceException. When I react within these 10 seconds there are no problems. The session state settings are:
<sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="false" timeout="20"/>
Does anyone have an idea what can cause this?
|
|
|
|
|
Hi,
In DayRender Event of a calendar, I have bind data to a radioButtonList:
rblTimes.DataTextField = "Time";
rblTimes.DataValueField = "Time";
rblTimes.DataSource = dtFreeTime;
rblTimes.DataBind();
that dtFreeTime is a DataTable that I filled it in above event,(It must fill dynamically, related to calendar and the data is not from DB. It's some numbers that calculate related to calendar).
Now, In Click event of a button, I want to know which item of radioButtonList is selected,but it always return -1 for selectedIndex.
I think because the datasource of radioButtonList is dynamic, it disposed and selectedIndex is missed.
now, How can gain the selectedIndex?
Best wishes
|
|
|
|
|
May be you should maintain the dtFreeTime DataTable in the Session or whatever. Bind it whenever it is necessary.
|
|
|
|
|
Have you tried ViewState? Also, are you putting RadioButtons on each row in the DataTable? If so, you just need to find out which DataTableRow was clicked and get the instance of the RadioButton on that row.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
Have what we believe to be an issue with caching in master pages or IIS or C# in general. We have a site where we give X number of resources to a user per day. In this example we are giving them 100 Wheat for every Farm they have per 24 hour period.
We store the last DateTime.Now.Tick value in their user profile in the SQL database. When they refresh a page, it reads the current DateTime.Now.Tick value and compare the two and then do the following math to compute hoe much more production they should have.
dLogs = ((dtNow.Ticks - lLastUpdateTicks) * production / (864000000000.0 * Globals.PERIOD));
This formula of course works but I have to refresh the page twice to get the proper values. The first time I refresh it gives me just a few ticks update worth of the Wheat. Here is the begining of the function...
<br />
public GameEvents(int UserID)<br />
{<br />
intUserID = UserID;<br />
dtNow = DateTime.Now;<br />
<br />
SqlDataReader rdr = null;<br />
SqlConnection connection = null;<br />
<br />
try<br />
{<br />
string szConnection = System.Configuration.ConfigurationManager.AppSettings["SQLConnection"];<br />
<br />
connection = new SqlConnection(szConnection);<br />
<br />
string szQuery = "SELECT LastUpdate FROM King WHERE (ID = @UserID)";<br />
<br />
SqlCommand cmd = new SqlCommand(szQuery, connection);<br />
cmd.Parameters.AddWithValue("@UserID", intUserID);<br />
<br />
connection.Open();<br />
<br />
rdr = cmd.ExecuteReader();<br />
<br />
while (rdr.Read())<br />
{<br />
lLastUpdateTicks = rdr.GetInt64(rdr.GetOrdinal("LastUpdate"));<br />
}<br />
So we get the current DateTime and the value out of the database of our last update and then do the following math to compute the resources they should have gained as follows...
<br />
<br />
dLogs = ((dtNow.Ticks - lLastUpdateTicks) * production / (864000000000.0 * Globals.PERIOD));<br />
<br />
We should not have to refresh twice to get a complete update. We know it is the DateTime issue and believe it is a cache issue or something like that as the resources are updated a few ticks with the first refresh which tells me that it is not just failing to run the code. Then on the second refresh it updates to where it should be as far as number of resources.
Guess the net of the question is: "Does master pages or IIS or whatever it is cache this DateTime.Now() and not go out to the system each and every time?" If not what else coudld be the problem!
Any help would be greatly appreciated!!!
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
Expert Coming wrote: Guess the net of the question is: "Does master pages or IIS or whatever it is cache this DateTime.Now() and not go out to the system each and every time?"
No, of course not. You are reaching for straws...
Expert Coming wrote: If not what else coudld be the problem!
The order that you do things in the page, perhaps.
You are looping through the result you get from the query and keeping the last value... Do you have more than one record per user?
Have you stepped through the code or displayed the values that you get so that you see what's really happening?
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
I cannot really step through the code as I do not have remote debugger setup. But like I said before, it works fine if you stay active on the page, if you wait like 2 or 3 minutes the pages has what I can only describe as a cache effect and only updates a few seconds worth, then if I get active again after that, it works correctly.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
Exception Details: System.UnauthorizedAccessException: Access to the path 'd:\hosting\u4arabeya\jobs\addcv11\CVs\Answers to Non-Muslims.pdf' is denied.
ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user
and when i add the impersonate with the user name and password it aslo desn'et work
any help please
|
|
|
|
|
The user account that your website is running under doesn't have the rights to access this location. If you are uploading to this directory, right-click the directory in Windows Explorer, select 'Security' and grant the user account Write access.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Dear Friends,
Actually this is my first project in which i create an ASP.net web site i want some global data which i stored in Resource.resx file and i create solution for some business logic now each time i have to pass the Resource.resx file data to solution at any page or button event can it is possible to access the resource file of that web site from the soution itself so it could be centralise at solution level.
[Solution (Bussiness Logic)] - [Resource File (Centralise Info)] - [Web page (Front End)]
is this a good idea or i thinking something which is not possible.
i am using Microsoft Visual Studio 2005 (Framework 2.0)
Thanks in advance
Sasmi
|
|
|
|
|
i dont know how did you store the global data in resx file. As per my knowledge resx file is automatically created for an aspx and it only holds the data of the page. I dont know how to call resx file in the code but i have a suggestion...Dont make the code too complicated..if you want the global data to be stored then create a separate class...while deploying use x copy deployment where you only use dll...hope this will help you...
bzinez
|
|
|
|
|
It's always a good practice to keep the string values which is common to the application in a assembly resource file.
In Framework 2.0, accessing the named strings from assembly resource file has been made very simpler. You have to add the resource file to the App_GlobalResources folder and add the named strings to the resource file.
Say for an example, you have added a resource file with the name GlobalData.resx and a string ApplicationName with the value "Sample Application". The named strings you add to a global resource file are accessible through a namespace named Resources . It takes a single line of code...
lblAppName.Text = Resources.GlobalData.ApplicationName
- Regards - J O N
A good thing is a bad thing if it keeps you from the best thing. - Dr. Adrian Rogers
|
|
|
|
|
how i can make a list box to show the data in the columns manner
like this
col1 col2 col3
1 2 4
and user can select 1 or 2 or 3
|
|
|
|
|
jagadeeshkumar2106 wrote: how i can make a list box to show the data in the columns manner
You can't. Use some grid-based control instead and provide the user with the ability to select rows of data.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
what is difference between asp.net and C#.net
arivazhagi
|
|
|
|
|
ASP.NET is web technology. You can use either C# or VB.NET to create the ASP.NET application.
|
|
|
|
|
arivazhagi wrote: what is difference between asp.net and C#.net
asp.net is 1 character longer than C#.net
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
C# is a language
ASP.NET is a framework.
|
|
|
|
|
arivazhagi wrote: what is difference between asp.net and C#.net
hi there,
First of all c# is a language and ASP.net is web technology which is used for development of web sites and web services. For the development of website using ASP.net we can use any of the languages c#, VB, c++, j# which is provided by Visual Studio 2005. If we are using c# then we call c#.net, if we are using VB then we call VB.net. It is simple naming convention which specifies which language is used for development of any project.
Hope this will help you.
Thanks &Regards
Dilip Kumar VIshwakarma
|
|
|
|
|
Hello Friends,
I'm sending mail in ASP.NET 2.0 then it's raising the following error
Mailbox unavailable. The server response was: 5.7.1 Unable to relay for manoj.msb1984@gmail.com
|
|
|
|
|