rss
twitter
facebook

Home

How to clear Query string value in asp.net

PropertyInfo isreadonly = typeof(System.Collections.Specialized.NameValueCollection).GetProperty("IsReadOnly", BindingFlags.Instance | BindingFlags.NonPublic);
                // make collection editable
                isreadonly.SetValue(this.Request.QueryString, false, null);
                // remove
                this.Request.QueryString.Remove("id");
 
http://www.codeproject.com/Questions/310625/How-to-clear-Query-string-value-in-net 

Read More

Enabling NTLM Authentication (Single Sign-On) in Firefox

This HowTo will describe how to enable NTLM authentication (Single Sign-On) in Firefox.
How many of you have noticed that when you are using Internet Explorer and you browse to your companies intranet page that it will automatically authenticate you but when you use Firefox you will be prompted with a login box?
I recently, in searching for solutions to allow NTLM authentication with Apache, stumbled across how to set a preference in Firefox that will pass the NTLM authentication information to a web server. The preference is network.automatic-ntlm-auth.trusted-uris.
So how do you do it?
1) Open Firefox and type "about:config" in the address bar. (without the quotes of course)
2) In the 'Filter' field type the following "network.automatic-ntlm-auth.trusted-uris"
3) Double click the name of the preference that we just searched for
4) Enter the URLs of the sites you wish to pass NTLM auth info to in the form of:
http://intranet.company.com,http://email.company.lan
5) Notice that you can use a comma separated list in this field.
6) Updated: I have created VBScript that can be used to insert this information into a users prefs.js file by using group policy or standalone if for some reason you want to use it for that.


http://sivel.net/2007/05/firefox-ntlm-sso/
Read More

how to format datetime in gridview for minutes OR Date



FORMAT MINUTES
<asp:BoundField DataField="HoraAT" HeaderText="Hora" ReadOnly="True" SortExpression="HoraAT" DataFormatString="{0:hh}:{0:mm}" />


FORMAT DATE

<asp:BoundField DataField="CriatedOn" HeaderText="CriatedOn"  DataFormatString="{0:yyyy-MM-dd}"      SortExpression="CriatedOn" Visible="false"/>
Read More

Howe to make random top X rows sql

SELECT TOP [Number]  [Field] FROM [TableName]
ORDER BY NEWID()


Read More

How to convert DateTime to Hour / Minute / Second

SELECT
CONVERT(VARCHAR(8) , GETDATE() , 108) AS HourMinuteSecond,
CONVERT(VARCHAR(5) , GETDATE() , 108) AS HourMinute

Read More

How to make UPDATE SELECT

UPDATE [TableName]
SET [Field]= BB.[Field]
                  FROM [TableName] BB
                                        INNER JOIN [TableName] AA ON BB.[Field] = AA.Field
Read More

Javascript LOGON_USER



SyntaxEditor Code Snippetvar WinNetwork = new ActiveXObject('WScript.Network');
document.getElementById('"+Logon.Id+"').value = WinNetwork.UserName;

Read More

SCCM Programs used by users in the last 7 days

SELECT DISTINCT DATEDIFF(DAY, rua.lastusedtime0, GETDATE())AS[Days Since Last Used]
,sysvalid.netbios_name0 AS [Computer Name]
,rua.productname0 AS APPLICATION
,rua.filedescription0 AS [File Description]
,rua.explorerfilename0 AS [File Name]
,rua.fileversion0 AS [File Version]
,rua.companyname0 AS publisher
,CASE WHEN ( ISNULL(rua.productcode0, N'') = N'') THEN 'N'ELSE 'Y'END AS [Associated with an Installer]
,rua.lastusedtime0 AS [Time Last Used(GMT)]
,rua.lastusername0 AS [Last Used By]
,rua.TimeStamp
FROM [dbo].v_gs_ccm_recently_used_apps AS rua
                              LEFT JOIN[dbo].v_r_system_valid AS sysvalid ON rua.resourceid = sysvalid.resourceid                       
WHERE lastusername0 Like '%@user%' AND rua.ExplorerFileName0 NOT LIKE '%.tmp' AND rua.fileversion0 NOT LIKE ''
AND  DATEDIFF(DAY, rua.lastusedtime0, GETDATE())<=7
Read More

SCCM DETAILS DISK

 /********** DETAILS DISK *****************/
 SELECT GD.InterfaceType0,GD.Name0,(GD.Size0),gd.Partitions0,GD.ResourceID
 FROM [dbo].[v_GS_DISK] GD
 WHERE GD.ResourceID=@ResourceID

  /********** DETAILS DISK *****************/
 SELECT Ld.Description0,ld.DeviceID0,Ld.FileSystem0,LD.FreeSpace0,LD.Size0,LD.VolumeName0
 FROM [dbo].[v_GS_LOGICAL_DISK] LD
 WHERE LD.ResourceID=@ResourceID
Read More

SCCM 2012 View installer programs by ResourceID

SELECT vARP.DisplayName0, vARP.Publisher0, vARP.Version0 ,vARP.InstallDate0,vARP.TimeStamp
FROM[dbo].v_Add_Remove_Programs vARP
JOIN  [dbo].v_R_System vRS ON vARP.ResourceID = vRS.ResourceID 
WHERE vRS.ResourceID = @ID
Read More

SCCM Disk space for all servers IN C:

SELECT DISTINCT VFCM.Name,VGL.DeviceID0, VGL.Description0, VGL.VolumeName0,
VGL.FreeSpace0 as [Free(MB)],
VGL.FreeSpace0/1024 as [Free(GB)],
VGL.Size0/1024 as [Total(GB)],
VGL.FreeSpace0*100/VGL.Size0 AS X
FROM[dbo].v_FullCollectionMembership VFCM
JOIN [dbo].v_GS_LOGICAL_DISK VGL on VFCM.ResourceID = VGL.ResourceID
JOIN[dbo].v_R_System VRS ON VFCM.ResourceID = VRS.ResourceID
WHERE
VGL.DriveType0 =3
AND VGL.DeviceID0 = 'C:'
ORDER BY VFCM.Name, VGL.DeviceID0
Read More

Chassis type values in SCCM

when 1 then 'Other'
 when 2 then 'Unknown'
 when 3 then 'Desktop'
 when 4 then 'Low Profile Desktop'
 when 5 then 'Pizza Box'
 when 6 then 'Mini Tower'
 when 7 then 'Tower'
 when 8 then 'Portable'
 when 9 then 'Laptop'
 when 10 then 'Notebook'
 when 11 then 'Hand Held'
 when 12 then 'Docking Station'
 when 13 then 'All in One'
 when 14 then 'Sub Notebook'
 when 15 then 'Space-Saving'
 when 16 then 'Lunch Box'
 when 17 then 'Main System Chassis'
 when 18 then 'Expansion Chassis'
 when 19 then 'SubChassis'
 when 20 then 'Bus Expansion Chassis'
 when 21 then 'Peripheral Chassis'
 when 22 then 'Storage Chassis'
 when 23 then 'Rack Mount Chassis'
 when 24 then 'Sealed-Case PC

Ref:http://blogs.technet.com/b/breben/archive/2009/07/21/chassis-type-values-in-sccm.aspx

Read More

trick folder GodFolder

GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}
Paste this name folder :) Enjoy

Read More

How to make SQL Backup All DataBases

DECLARE @Baksql VARCHAR(8000)
DECLARE @BackupFolder VARCHAR(100)
DECLARE @BackupFile VARCHAR(100)
DECLARE @BAK_PATH VARCHAR(4000)
DEclare @BackupDate varchar(100)
-- Setting value of  backup date and folder of the backup
SET @BackupDate =  REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR,GETDATE(),120),'-',''),':',''),' ','_') -- 20110517_182551
SET @BackupFolder = 'C:\Backups\'
SET @Baksql = ''
-- Declaring cursor
DECLARE c_bakup CURSOR FAST_FORWARD READ_ONLY FOR 
SELECT NAME FROM SYS.DATABASES
WHERE state_desc = 'ONLINE' -- Consider databases which are online
AND database_id > 4  -- Exluding system databases

-- Opening and fetching next values from sursor
OPEN c_bakup
FETCH NEXT FROM c_bakup INTO @BackupFile
WHILE @@FETCH_STATUS = 0
BEGIN
SET @BAK_PATH = @BackupFolder + @BackupFile
-- Creating dynamic script for every databases backup
SET @Baksql = 'BACKUP DATABASE ['+@BackupFile+'] TO DISK = '''+@BAK_PATH+'_FullBackup_'+@BackupDate+'.bak'' WITH INIT;'
-- Executing dynamic query
PRINT (@Baksql)
EXEC(@Baksql)
-- Opening and fetching next values from sursor
FETCH NEXT FROM c_bakup INTO @BackupFile
END
-- Closing and Deallocating cursor
CLOSE c_bakup
DEALLOCATE c_bakup
Read More

Field GridView with Link with Parameter

<asp:HyperLinkField Text="&lt;img src='../Img/view.png' alt='alternate text' border='0'/&gt;"
                    DataNavigateUrlFields="Id"  DataNavigateUrlFormatString="PAGE.aspx?Id={0}"
                    HeaderImageUrl="../Img/view.png" >
                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                </asp:HyperLinkField>
Read More

Object Data Source Select Parameter

<SelectParameters>
 <asp:ControlParameter ControlID="field" DbType="String" DefaultValue="1" Direction="Input" Name="ParameterName"  PropertyName="Text" />
</SelectParameters>
Read More

DataGridView COL with Image

<asp:TemplateField>
 <ItemTemplate>
  <asp:Image ID="Image1" Height="32px" runat="server" ImageUrl='<%# String.Format("{0}{1}{2}", "PATH", Eval("FIELD"),".jpg") %>' />
 </ItemTemplate>
 <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:TemplateField>
Read More

Convert short


Convert.ToInt16(field)


Read More

How to view Server Variables

foreach (string x in Request.ServerVariables)
{
Response.Write(x +
": " + Request.ServerVariables[x] + "<br>");
}
Read More

NTLM - ASPX C#


Properties project

Servers

click checkbox -> NTLM authentication

web.config

<authentication mode="Windows">
</
authentication>

IIS

Authentication -> windows authentication -> Enable
Authentication -> windows authentication -> Providers -> put NTLM first 
Read More
 
Powered by Blogger