Lets Have a fun with Technology.

BTemplates.com

Follow by Email

Monday, December 14, 2009

Calendar Extender Problem When Control Set to Read only.



Problem: - Calendar Extender Problem When Control Set to Read only.
<asp:TextBox id="txtdate" runat="server" Width="229px" Enabled="False">
asp:TextBox>
<cc1:calendarextender id="Calendarextender1" runat="server" TargetControlID="txtdate" PopupButtonID="imgdate" Format="dd/MM/yyyy">
cc1:calendarextender>

Solution:-
When we using ajax calendar extender control we always need to set it property to Enable= True.
If you make enable=false then ajax control extender value you not getting at server Side. Below is reason for it.
When we set any Textbox Property to read only. its value can not process on a server side because of prevent of malicious data. How ever you can access that control on server side and perform operation which you want.But at server side you can not process value from textbox because of security reason.

Still if you want to make this working then Do one trick.
Make contentEditable="false" This work for you.


Wednesday, November 18, 2009

Unable to find a runtime version to run this application


Sometimes you find that you’re running application give message that “Unable to find a version of the runtime to run application
This problem occurred when DLL of Software get corrupted it may be frame work corrupted or your project dll corrupted.
To solved this Problem first try to repair framework.
If then also error not solved then replace your dll and/or exe with fresh dll and/or exe.

This Solved your Problem

Print (Perform operation on) all Data of Gridview when AllowPaging=True



Hello Frd’s

There may be case when you want to print data from gridview.Here Problem is not with Printing but when allowpaging=true it’s only possible to perform operation on a data which exists in a given page.

But there are trick using which you can print or perform operation on all gridview data.First of on print button click make AllowPaging="False" after this again bind data with gridview and perform prinitng or what ever operation with all filed of gridview.

After your work finished agaain make AllowPaging="True"

If you want to manage checkbox value during paging then read below article.

Monday, November 16, 2009

LINQ Advantages


Hello Frd's

Lets Discuss LINQ Advantages


In my point of view LINQ reduce my Data Access layer code.

Passing value to store procedure ,retrieve some parameters from store procedure is now easy for me.

Without linq i have to pass the parameters and doing all other stuff that required ...  thanks to linq which reduce my that stuff and speeder my development.

sometime during development of old style code there are problem of data type miss match . but in linq it's check in build time       wow ......



Please Cont your comments ........





Monday, August 10, 2009

Delete Temporary File From ASP.Net


Hello Frd's

There are often required to delete temp file which created during asp.net pages hit.you can delete this temp files either mannualy or by coding.

to delete temp file using Coding follow the below Step.

Store Temp File Path in Session["pdfpath"]


Write below code in global.aspx


void Session_End(object sender, EventArgs e) {
if (System.IO.File.Exists(Session["pdfpath"].ToString()))System.IO.File.Delete(Session["pdfpath"].ToString()); }

in web.config
<sessionState mode="InProc" timeout="20">
sessionState>




this Code delete your temp file.

Please do not forgot to comment on articles.


Saturday, August 8, 2009

'sys' is undefined


Problem :-  'sys' is undefined

Solution :-


1. Sys undefined usually indicates that the framework scripts didn't load. In your case, you shouldn't drop the script files directly under the script path: there is versioning involved and the directory structure must be exactly what the script manager expects.
If you look at the html source code in the browser, you'll see what the expected url is for each script. You need to reproduce that directory structure on your server. The directory structure of the library as downloaded from the asp.net site should already be the right one.


2. There are many reasons for getting this error . Few of them i encountered were
1) Web.config not getting updated according to the AJAX enabled website requirement  because most of us are using in existing application and trying to make it work and we miss few entries . Best option is to create an AJAX enabled website and put all the web.config entries into exixting application's web.config or put the exixting aplication web.config entries into newly created website web.config and replace the original one  with new one.
2) If issue is not related to web.config  then its possible that system is not allowing IIS to access the file system where the MicrosoftAjaxLibrary exists usually C: drive. In most of the production environment its not allowed so we need to make use of scriptpath attribute of scriptmanager and it may solve the issue as mentioned in above post where scripts folder is in ur website directory and all the ajaxlibrary java script files are copied into this folder.
3) Even after this it doesnt work then you need to look if the file can be accessible from client machine may be system configuration is not allowing to access it use HTTPWATCH or FIDDLER to see if 404 is coming if so then it has to do with system settings in my case it was ISAPI filter which was causing it and it was URLSCAN security tool which was not allowing it why because of MicrosoftAjaxLibrary contains the folder names which has DOTS(.) like System.Web.Extensions . So we need to modify the .ini file for urlscan security tool ISAPI filter. To do this you need to check if this filter is added in ur IIS if so then you need to go to WINDIR%\System32\Inetsrv\URLscan  and edit th .ini file and make AllowDotInPath=1  this will solve the issue.
 These were my analysis hope it helps . again i reiterate that there is no fix scenario why this errors comes.Different person can get same error for different reasons.




ASP.NET 2.0 - Accessing controls in the previous page


One of the problems faced by us in ASP.NET 1.x versions is the inability to transfer data between pages easily. Since ASP.NET 1.x pages postback to the same page by default, and you cannot do a post to another page (unless you remove the runat="server" and other messy things), accessing the controls in the previous page becomes very difficult unlike classic ASP where you have a action tag to specify the new page and you can use the Request.Form to access the previous page values.
There is a more effective way of accessing the Controls in the previous page in ASP.NET 2.0. Its using the PreviousPage property of the Page.

Say we have a page Default.aspx with a Textbox "Text1" and a Button "Button1".

We can access the controls in Default.aspx from another page by the following steps:-

1. Setting the PostBackUrl property of the Button to the New Page, as follows:-



2. Then, in the NewPage.aspx.cs, you can access the TextBox control on Default.aspx as follows:-

public void page_load()
{
if(!IsPostBack)
{
TextBox tb = (TextBox)PreviousPage.FindControl("Text1");
Response.Write(tb.Text);}
}

Note that a new TextBox tb is declared and typecasted using the PreviousPage and FindControl of the ID of the Control in the Previous Page.  However, to retain the value across postbacks within the new page, its better to assign the text to a TextBox or Label in the NewPage.aspx such that its value is not lost across postbacks.  The reason behind is that, the PreviousPage becomes invalid once you postback in the same page. 



We could still achieve this in ASP.NET 1.x versions by using the Server.Transfer but Server.Transfer has other undesirable effects like URL not updated in the browser and limitation within the application etc., 






Note :- This artical taken from  http://forums.asp.net

Saturday, July 18, 2009

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


Problem :-
"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"

Solution :-


                This type of error msg you get when you are using Windows dialog box (Message box) to display message in it.

                if you are running application from local you not getting this error message but when you run this application form network you get this error msg.This because when you use windows message box it's interact with current running windows and for interaction windows required adminsistrator or Similar type prevailing user . instead of this use label to Print error or use java script alert or confirm.

                please reader write when you get this error msg in below comment box.








Saturday, July 11, 2009

Export Data in Word document from ASP.Net With Formating


Hello Frd's

It's easy task to Export Data in Word Document from asp.Net . look at below code.This Code Export Data in Word Document With Bold,Color ect ... Feature Whatever you do with HTML Table Data.



        Response.Clear();
        Response.Buffer = true;
        Response.AddHeader("content-disposition", "attachment;filename=Adfield.doc");
        Response.Charset = "";
        Response.ContentType = "application/vnd.ms-word ";


        //txtad.Value = str;
        StringWriter sw = new StringWriter();
        HtmlTextWriter hw = new HtmlTextWriter(sw);
        HtmlForm fr = new HtmlForm();
        HtmlTable TLB = new HtmlTable();
        TLB.Style.Add("Border-width", "1px");
        HtmlTableRow hdr = new HtmlTableRow();
        HtmlTableCell cell = new HtmlTableCell();
      
            // Take data From Database and Write with format


            hdr = new HtmlTableRow();
            cell = new HtmlTableCell();
            cell.Style.Add("BACKGROUND-COLOR", "Gainsboro");
            cell.InnerHtml = "Client Name";
            hdr.Cells.Add(cell);
            cell = new HtmlTableCell();
            cell.InnerHtml ="";
            hdr.Cells.Add(cell);
            TLB.Rows.Add(hdr);


     //At last


            fr.Controls.Add(TLBdetail);
           this.Controls.Add(fr);
           fr.RenderControl(hw);
          Response.Output.Write(sw.ToString());
          Response.Flush();
          Response.End();




Friday, July 10, 2009

Thursday, July 9, 2009

Where to Buy Domain name


Every web master has a question from where to buy a domain name. Now a day domain booking is a normal process some booked domain for their business, some booked for personal use, some booked for social activity.

For any reason every day there are thousands of domain name booked every day. There are lots of domain Provider site which booked our domain name but necessary thing is payment and billing address. For that I am always follow godaddy.com. godaddy.com booked my domain name within a minutes.

I am not suggesting godaddy.com because of it is famous in word but it is one of greater solution for domain and space. They provide Support also very fast and answer goes to our
Solution.

I am always prefer it if you have any other then post on a comment with feature they provide and facility.

Wednesday, July 8, 2009

Search Result



What is MVC (Model view Controller)



MVC is framework methodology that divides application into three components roles.
Model
View
And Controller
1.       Model
Model in MVC based application are component which maintain the state. Often this state is persisted inside a database.
2.       Views
Views in the MVC based application are the components responsible for displaying the application user interface.
3.       Controllers
Controllers in MVC based application are the components responsible for handling end user interaction, manipulating the model and ultimately choosing a view to render to display UI. In MVC view is only to displaying information it is controller that handles and response to user input and interaction.
The Basic Diagram for MVC can be given by 

Wednesday, June 10, 2009

Problem With margin in different Browser (Chrome,Safari,Firefox,IE)




Hello Frd’s there are Problem with Different Browser if we give margin in Control.
I have Solution for it.
I also give articles provided by http://www.w3.org/ .It’s nice article I love it.
Margin not makes Problem in IE and FF. It’s Work fine but for Chrome
And Safari its make Problem margin not set for controls.
Before we go for article set Body of your Page Margin to 0
<body style="margin-left: 0; margin-right: 0; margin-top: 5px; margin-bottom: 0; background-color: #FFEED9;">”

Horizontal margins never collapse.
Vertical margins may collapse between certain boxes:
  • Two or more adjoining vertical margins of block boxes in the normal flow collapse. The resulting margin width is the maximum of the adjoining margin widths. In the case of negative margins, the maximum of the absolute values of the negative adjoining margins is deducted from the maximum of the positive adjoining margins. If there are no positive margins, the absolute maximum of the negative adjoining margins is deducted from zero. Note. Adjoining boxes may be generated by elements that are not related as siblings or ancestors.
  • Vertical margins between a floated box and any other box do not collapse (not even between a float and its in-flow children).
  • Vertical margins of elements that establish new block formatting contexts (such as floats and elements with overflow other than 'visible') do not collapse with their in-flow children.
  • Margins of absolutely positioned boxes do not collapse (not even with their in-flow children).
  • Margins of inline-block elements do not collapse (not even with their in-flow children).
  • If the top and bottom margins of a box are adjoining, then it is possible for margins to collapse through it. In this case, the position of the element depends on its relationship with the other elements whose margins are being collapsed.
    • If the element's margins are collapsed with its parent's top margin, the top border edge of the box is defined to be the same as the parent's.
    • Otherwise, either the element's parent is not taking part in the margin collapsing, or only the parent's bottom margin is involved. The position of the element's top border edge is the same as it would have been if the element had a non-zero bottom border.
An element that has had clearance applied to it never collapses its top margin with its parent block's bottom margin.
Note that the positions of elements that have been collapsed through have no effect on the positions of the other elements with whose margins they are being collapsed; the top border edge position is only required for laying out descendants of these elements.
  • Margins of the root element's box do not collapse.

The bottom margin of an in-flow block-level element is always adjoining to the top margin of its next in-flow block-level sibling, unless that sibling has clearance.
The top margin of an in-flow block-level element is adjoining to its first in-flow block-level child's top margin if the element has no top border, no top padding, and the child has no clearance.
The bottom margin of an in-flow block-level element with a 'height' of 'auto' is adjoining to its last in-flow block-level child's bottom margin if the element has no bottom padding or border.
An element's own margins are adjoining if the 'min-height' property is zero, and it has neither top or bottom borders nor top or bottom padding, and it has a  'height' of either 0 or 'auto', and it does not contain a line box, and all of its in-flow children's margins (if any) are adjoining.
When an element's own margins collapse, and that element has had clearance applied to it, its top margin collapses with the adjoining margins of subsequent siblings but that resulting margin does not collapse with the bottom margin of the parent block.
Collapsing is based on the used value of 'padding', 'margin', and 'border' (i.e., after resolving any percentages). The collapsed margin is calculated over the used value of the various margins.

Saturday, May 30, 2009

Desing Problem in ASP.Net With Diffrent Browser Like Crome,Safari,Opera


Hello ,
in Asp.Net Menu There are Problem With Browser Like Crome,Safari,Opera.  Menu CSS Not display According to What we Have Done for Designing. Look Below Image Which Shown Problem In Above Browser With Design.


You can Solved this By writing Below Code in each Page or in Master Page It solved Your Problem.

if (Request.UserAgent.IndexOf("AppleWebKit") > 0)
        {
            Request.Browser.Adapters.Clear();
        }

See Below Image After Applying Above Coding.

Learn AJAX For Newbie ......


Hello Frd's

If you are New to AJAX and Want to Implement It. Then Just Go below Site.

First Download AJAX Tool Kit from below Site.download tool kit according to your Framework.


http://www.asp.net/ajax/downloads/

Second go online Sample to See Which control Suitable for your Site.

http://ajaxcontroltoolkit.com/

With tool Kit There are Sample example Provide With Source Code So you Can easily Learn it.

Other Frd's if you are having any more Information Related to AJAX which Help Other Please Contribute it Here.

Tuesday, May 26, 2009

send email using asp.net from gmail account


Hello Frd's

Below Code are For Sending Email From your gamil account to any other Account.It's Working Code you can directly run that Code Without Changing Any Value.

Or Change From , to , NetworkCredential

Code :-

MailMessage msg = new MailMessage();
msg.From = new MailAddress("ketantest.test@gmail.com");
msg.To.Add("ketan_erp@yahoo.com");
msg.Subject = "test";
msg.Body = "body";
msg.IsBodyHtml = true;
msg.Priority = MailPriority.High;
System.Net.NetworkCredential authorise = new
System.Net.NetworkCredential("ketantest.test@gmail.com", "ketantesttest");
SmtpClient spclient = new SmtpClient("smtp.gmail.com", 587);
spclient.EnableSsl = true;
spclient.UseDefaultCredentials = false;
spclient.Credentials = authorise;
spclient.Send(msg);

Thursday, May 14, 2009

3 Tier Architecture Application (Full Project)


Download Source Code from ASP.Net Site.


It's very good application to learn best programming methodogy. Application developed in 3 Tier Architecture.Whole application divided in User Interface layer,Business Logic layer and Data Access Layer.Application using Store Procedure.That's best methodology wo work with Database.Application developed using OOPS Concepts. if u want to make application whose performance is better,run faster then just go away for above Style.
Enjoy !!!!!

Thursday, April 30, 2009

How to restrict a user getting access to pages after logout


Problem :- How to restrict a user getting access to pages after logout

Solution :-

First Solution :-

You need to stop the browser from caching your pages,
place the following code in the Page_Load function of any page that you want to prevent the browse from caching it.

Response.Cache.SetCacheability(HttpCacheability.NoCache);

If you are using Master pages then u can also put this code in master
So each page can not access after logout.

Second Solution :-

if you are using Session in application then call abondon metohd for Session Destroy and then Redirect to login Page.Check Session in Master Pages if It's Not Exists then u can redirect user to other Page.


But First One is good One for this.

Failed to access IIS metabase.


Problem 

Failed to access IIS metabase.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.Hosting.HostingEnvironmentException: Failed to access IIS metabase.

The process account used to run ASP.NET must have read access to the IIS metabase (e.g. IIS://servername/W3SVC). For information on modifying metabase permissions, please see http://support.microsoft.com/?kbid=267904.
Solution :-
This Error Caused Because You Not Have Register ASP.Net with IIS.Please Follow Following Step to Regiser ASP.Net With IIS.
-> Go to Start - >  Run -> Cmd.

-> GO to Your System Drive Mostly C Drive.

-> Type C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -i
Just wait And Message comes Successfully Register.

Prev Post                                                      All Post                                                           Next Post

Wednesday, April 29, 2009

It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level


Problem :-  It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level

 

Solution :- There Are Mainly One of the Two Reason Why you Got this Error Message.

1.   If you Have Not configured your asp.net application in IIS.  If you have not Configure your application to run on IIS First Configure your Site to Run on IIS.For that Create Virtual Directory From IIS and Give Permission to Application (Read,Write)

 

2. If Above is Not Problem Then There are Mainly Problem of Two or many Web.Config Exists on your Site.When you Open Some Site and if Software Crate Backup of that Application then Software mainly Do Create Subfolder and Copy All Files + Web.Config in Application.Just Remove this Subfolder web.config from Subfolder. 

 

Let me Know if You Know Anything More or want to Know More .....

 . 

 

Prev Post                    All Post                           Next Post

Tuesday, April 7, 2009

DataBinding Method Such as Eval(),XPath(), and Bind() can Only be used in the Context of a databound Control.


 
Problem: - DataBinding Method Such as Eval(),XPath(), and Bind() can Only be used in the Context of a databound Control.

Solution :-   Use  DataBinder.Eval(Container.DataItem,"field_name")  Method

                    Instead of  Eval(“field_name”)

Description :- 

This Error Mainly Cause Because Of using Eval(“field_name”) Method to bind Control in Grid view.  Instead of Eval Method if we use DataBinder.Eval(Container.DataItem,"field_name") the Error Got Solved. I am Using Grid view from Last 2 Years but never got this Error before. But One Day When I use Nested Grid view this Error throw by .Net Compiler. If there is Only One grid view then Eval method is ok. Please if you have any extra Information Comment On this. In Comment Please Write How’s u got this Error and Solution you have done for this.


Thank you.

Monday, March 23, 2009

Count Number of Lines in TextArea (Textbox) With Word Wrap



Count Number of Lines in TextArea (Textbox) With Word Wrap
Java Script Function to Count Number of Lines with Word Wrap:-
< script type="text/javascript" >
function countLines(){
var theLines1 = document.getElementById("<%= txt_detail.ClientID %>");
var theLines = theLines1.value.replace((new RegExp(".{"+theLines1.cols+"}","g")),"\n").split("\n");
if(theLines[theLines.length-1]=="") theLines.length--;
document.getElementById("<%= txt_line.ClientID %>").value = theLines.length;
}
< /script >
Call This Java Script Function from where you Want count number Of Lines in TextArea.I am Display on Load of Control So I called its Before Content Tag Finished.
< script >
countLines();
< /script >
Count Number of Word and Character in Text Area
Used Following Extra Code in Your Java Script Function for Count Number of Character and Words.

var char_count = theLines1.value.length;
var fullStr = theLines1.value + " ";
var initial_whitespace_rExp = /^[^A-Za-z0-9]+/gi;
var left_trimmedStr = fullStr.replace(initial_whitespace_rExp, "");
var non_alphanumerics_rExp = rExp = /[^A-Za-z0-9]+/gi;
var cleanedStr = left_trimmedStr.replace(non_alphanumerics_rExp, " ");
var splitString = cleanedStr.split(" ");
var word_count = splitString.length -1;
if (fullStr.length <2) {
word_count = 0;}
document.getElementById("<%= txt_word.ClientID %>").value =
word_count;
document.getElementById("<%= txt_char.ClientID %>").value =
char_count;