Latest developer linksBookmark and Share
 
HomeThis WeekTop MonthTop AlltimeSearchRegisterFAQ
  
 
Submit Your Link
Please login to submit your Link
 

Problem on DateTime class

Posted: Dec/14/2010   By: nikhil   Points:15   Category: .NET  - ASP.Net    Views:141   Vote Up (0)   Vote Down (0)    

i tried to get current date and time using


              DateTime dtCurrTime = DateTime.Today;


            //string d
            Label1.Text = dtCurrTime.ToString();

            //DateTime dt = DateTime.Now.Hour;

            Label2.Text = DateTime.Now.Date.ToString();




 i'm getting the date correct but time is always getting default value


12/15/2010 12:00:00 AM

View Complete Post


Comments:
Be the first to comment this post.
 
Post Comment
Please login to post your comment
More Related Resources

problem in outlook

  

hello i am facing a problem in microsort outlook 2003.

i have an email template in html in which i am sending data from asp.net page and according to condition making display:none of sm <tr> dymamically.

it is working fine when received in outlook. but when we press forward button to forward mail

then hidden rows also displays.

Any idea to get rid of this problem.

Please suggest me



Strange problem with a button in a repeater

  

I've got a Imagebutton in a repeater.
Code:

<asp:Repeater ID="repImages"  runat="server">
                    <ItemTemplate>                       
                        <div>
                            <div><asp:ImageButton ID="btnDeleteImage" Width="7" Height="7" runat="server" AlternateText="Verwijder afbeelding"  OnClientClick="return confirm('Weet u zeker dat u deze afbeelding wil verwijderen?');" OnClick="ImageButton_OnClick" ImageUrl="~/images/spacer.gif" /></div>
                            <img id="imgImage" runat="server" src='<%# GetOccasionPath(int.Parse(Eval("ID").ToString()),Eval("BaseFileName").ToString(), TypeImage.thumbnail) %>' />
                        </div>
                    </ItemTemplate>
                </asp:Repeater> 

 

It is displayed well, but if i press the button btnDeleteImage he doesn't even run ImageButton_OnClick , also there is no data included just for testing...
protected void ImageButton_OnClick(object source, EventArgs e)
    {
       
    }

 

But still i get this error:

Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

Also enableEventValidation="true" is placed in the page.
What can i do to solve this?


Validation metadata problem in MVC3 R2 with class inheritance

  

HI

My project upgrade to MVC3 R2, but there is a problem with validation metadata when the model inherit from other class.  In MVC2 all the child class will inherit the validation metadata, but in MVC3 R2, it will be not include the validation metadata of parent class. Is this expected?


SVN problem

  

Hello

I am using Visual SVN Server and Tortoise SVN as a Client. 

After I get update and ascx file is merged visual sdutio displays warning and I must set merged file line encoding.

The line endings in the following file are not consistent. Do you want to normalize line endings?


I believe that it's due to default SVN merge tool or visual svn behaviour for currently opened files. 



Exporting DataSet to Excel in asp.net problem

  

Hi,

      I'm trying to export a dataset to excel directly. I'm repeating, it's a dataset to excel (NOT DATA GRID OR GRID VIEW TO EXCEL). The problem I face is formatting. I'm exporting the excel which has aroung 13 columns.

    A column should be in dd/MM/yyyy 00:00:00 format. Time will always be 00:00:00. It is exporting in correct format only, but for example when the date is Jan 05, 2010, when it comes from database it shows correct format as 05/01/2010 00:00:00. When it binds, it binds as 5/1/2010 00:00 which is not suppose to happen.

 And the other problem is with the decimal formatting. I need 2 decimal places at the last. In c# code, I'm converting to decimal with 2 decimal places, but when it binds, it won't happen. I tried inserting a ' (colon) before the text is entered, but the cell is not converted into a text field Foot in mouth

   Can anyone give me a solution for this?


grid view without any data source date sorting problem

  

i grid view contain the following coloum

id    name         DateofBirth                  DateofJoining 

1       a            22-Aug-1980                      10-jan-2000

1       a            22-may-1980                      20-feb-2000

1       a            12-Feb-1980                      15-mar-2000

1       a            3-Aug-1980                      7-jan-2000

how to sort if we click   DateofBirth or Dateofjoining and not sort any where if we click(Id,Name)


Problem with Server.Transfer in IE

  

I have the following code:

Protected Sub btnAdmin_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Server.Transfer("~/Admin/Default.aspx")
End Sub

that runs when a user clicks the admin button

It works fine in firefox, but in IE it doesn't work.
 


access to web form from class

  

hey,

i've read several posts with similar but problems, but i can't find one exactly like what i am seeing.  This is probably very simple...i just can't get the exact solution.

Platform is c#, VS 2010.

I have a web form and code behind file, with scripting that works just fine.  i'm trying to move script from the code behind file into a class, to consolodate and create re-use. The basic problem is when i move the script into the class, i cannot access the webform.

error here on "this":   HyperLink hyplAlertbox = (HyperLink)this.frmEtsuHome.FindControl(codeboxID);

i know WHY it throws the error, i just don't know how to fix it.  any help is appreciated.

below is simplified code....

------------------------------------------------------------------------------------------------

New Script in Code Behind File:


namespace myhome
{
    public partial class _default : System.Web.UI.Page
    {
                    
        protected void Page_Load(object sender, EventArgs e)
        {
             new majorAlerts();
             majorAlerts.GetAlerts();
             majorAlerts.ProcessAlerts(); } } }

-------------------------------------------------------------------------------------

Code for the Class

-------------------------------------------------------------------------------------


using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls.WebParts;

namespace myhome
{
    public class majorAlerts
    {
        
        public static void GetAlerts()
        {
            // grab the alerts and store them in a list                     
        }

public static void ParseAlerts(List<Alert> lAlerts) {
            foreach (Alert Alert in lAlerts) { // create codebox ID codeboxID = "codebox" + index.ToString(); // find hyperlink with ID of codeboxN cand reate an instance of it HyperLink hyplAlertbox = (HyperLink)this.frmMyHome.FindControl(codeboxID);

//******************* ERROR *************************************************
// ERROR ON this in previous line.  i understand, because "this" is not the form like it is in the code behind file.
// but i don't know how to modify "this" and make it work from class file
// **************************************************************************

 // set hyperlink URL value for alert based on alert ID alertURL = "http://www.blah.com"; hyplAlertbox.NavigateUrl = alertURL; } }




nested gridview problem

  

Hi I want a simple nested gridview to display data records, that's it, very basic no edits, etc. Just when user clicks on grid a nested grid

appears for order showing.  Right now I get an error, object expected when I click on the grid defaulting at runtime. I don't have

gifs for images, or an image folder, I don't think that would cause an error, or the second grid not to display???

Here's my code. Any help would be deeply appreciated. Many thanks!

<script>
 
   function switchViews(obj,row)
        {
            var div = document.getElementById(obj);
            var img = document.getElementById('img' + obj);
           
            if (div.style.display=="none")
                {
                    div.style.display = "inline";
                    if (row=='alt')
                      {
                           img.src="Images/expand_button_white_alt_down.jpg" mce_src="Images/expand_button_white_alt_down.jpg";
                       }
                   else
                       {
                           img.src="Images/Expand_Button_white_Down.jpg" mce_src="Images/Expand_Button_white_Down.jpg";
                       }
                   img.alt = "Close to view other customers";
               }
           else
               {
                   div.style.display = "none";
                   if (row=='alt')
                       {
                           img.src="Images/Expand_button_white_alt.jpg" mce_src="Images/Expand_button_white_alt.jpg";
                       }
                   else
                       {
                           img.src="Images/Expand_button_white.jpg" mce_src="Images/Expand_button_white.jpg";
                       }
                   img.alt = "Expand to show orders";
               }
       }
  
</script>

<div>
  &nbs

MVC3 RC2 Problem with VB ModelType and Razor

  

We tried to add a Entity model using Razor here was the syntax:

@ModelType BID.Data.Entities.PlumbingPermit
@Code
    ViewData("Title") = "Index"
    Layout = "~/Views/Shared/_Layout.vbhtml"
End Code
<h2>Index</h2>
@Html.EditorForModel 

@ModelType BID.Data.Entities.PlumbingPermit

@Code

    ViewData("Title") = "Index"

    Layout = "~/Views/Shared/_Layout.vbhtml"

End Code

<h2>Index</h2>

@Html.EditorForModel 

When you build you get the following error message:

Error 1 Syntax error. C:\Documents and Settings\thacker\My Documents\Visual Studio 2010\Projects\Public Works\BuildingInspectionsSystem\Source Code\BID.Web.VB\Views\Home\Index.vbhtml BID.Web.VB

if you comment out the @ModelType everything complies and displays correctly but it is not strongly typed.

We try this in C#:
@model BID.Data.Entities.PlumbingPermit

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Index</h2>
@Html.EditorForModel()

And everything worked. Is there an issue with model binding in VB?

Thanks!
Tim



 
Categories:
.NET
Java
PHP
C/C++/VC++
HTML/XML
SAP
MainFrames
Data Warehousing
Testing
MySQL
SQL Server
Oracle
Javascript/VB Script
Others
Login
 
 
 
 
 Forgot password
 Contact Us   Terms Of use   Share your knowledge