Wednesday, December 21, 2011

Display Image from Database in ASP.NET

Scenario -

I have image names (eg:- abc.jpg) saved in a database & actual images lie in a folder in file system (~/ClientImages/).

Now I want to retrieve image from db & diplay it on webpage,in a div

Solution :-
 It is a very basic method,You can also fill the datagrid from CS file,But I opted dirty approach ie.SqlAdaperSource Take a Gridview choose - DataSource (ie :- SqlDataAddapter,go through the wizard ).

DataKeyNames="id" DataSourceID="SqlDataSource1">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Image ID="img12" runat="server" Width="600px" Height="400" ImageUrl='<%# Page.ResolveUrl(string.Format("~/ClientImages/{0}", Eval("image"))) %>' />

</ItemTemplate>
</asp:TemplateField>

</Columns>

</asp:GridView>


## SqlDataSource ##
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:XXXXConnectionStringName %>"
SelectCommand="Stored_Procedure_Name" SelectCommandType="StoredProcedure">
</asp:SqlDataSource

Monday, December 19, 2011

Checkbox Validation in ASP.NET

Validation of check box is little bit tricky  but you can validate with Java Script

Add this script in the page.


<script type="text/javascript">
    function validateCheckBox(source,args)
    {
        var cb=document.getElementById("Privacy1");
        if(!cb.checked)
         args.IsValid=false;
    }
    </script>
add a Checkbox Control

<asp:CheckBox ID="Privacy1" runat="server"></asp:CheckBox>
Now you need to add a custom Validator:-

  <asp:CustomValidator ID="CustomValidator1" runat="server" 
            ErrorMessage="CustomValidator" 
            ValidateEmptyText="True" ClientValidationFunction="validateCheckBox"></asp:CustomValidator>



Tuesday, December 6, 2011

How to make free trials last FOREVER!!!


How to make free trials last FOREVER!!!

Difficulty : Piece of Cake 

You can make any software work for life time.          
        
 I am taking example of “ADOBE FLASH CS5 PROFESSIONAL “  Trial version as an example


Here we go  ->
  • First download any trial software(Flash CS5)
  • Type       runasdate        in Google          
  • Open 1st displayed page  most probably      nirsoft.
  • Download the software which is free.
  • Extract it  & run .
  • Then the first option will be application to run .Select desired(CS5)  application’s exe file's path.
  • Now,set a date/time  Make it sure it must be in the trial period. (you can set same date when application is installed or next day’s  date)
  • Check both  radio button, (move the time forward a/c to the real time  & immediate mode)
  • Create a new desktop shortcut   with desired name (eg:- RippedCS5 ).
  • Click   RUN  
  • That’s it
  • This procedure is  required only for 1st time , make sure to make a shortcut & only use that shortcut  on desktop. Configure every trial software with this utility & create short cut then u don’t need to run it again-2                       


                                                                                                   ENJOY

Monday, December 5, 2011

Test Stored Procedure Manually in MS SQL

Write a stored procedure  eg :  sp_Insert_Client_info

Now on New Query window  execut it with stored procedure's required value,

 like this  sp_Insert_Client_info'Age','India','phone',10101

Above sp will take 3 arguments/values :

  1. Age  or text value
  2. India or Text vale
  3. 10101  or integer value


Another example:

 sp_Insert_Client_Info'Jhon','sharma',87