29/12/2010

Sharepoint Portal

Al Madinah Regional Municipality:

http://www.amana-md.gov.sa/



Read more...

Sharepoint Portal

Jazan University:


http://www.jazanu.edu.sa/


Read more...

14/12/2010

MultiLine TextBox Issue With Chrom Browser

To prevent users from enlargement the multi line text box control,add the following CSS property:

resize: none

Only!!!


Read more...

11/12/2010

Riyadh Community Summit - 23 December 2010



You are invited to the following event:
Riyadh Community Summit (December2010)

Date:
Thursday, December 23, 2010 from 12:30 PM - 5:30 PM (GMT+0300)

Location:
King Fahad - North Between Exit 4 and 5 Going to Al Qassim
Riyadh 11512
Saudi Arabia

For more information click here




Read more...

13/11/2010

Adding Client Confirmation

To add client confirmation, such us when you want delete item:



OnClientClick = '<%#Eval("FieldName", "Javascript:return confirm(\"{0}\")") %>'

Read more...

02/11/2010

web service: The test form is only available for requests from the local machine.

if you create aweb service, and you want to test it from another server machine, the follwoing message will be appear:
"The test form is only available for requests from the local machine."
so, you should add the follwoing code into your web.config:
<webServices>
    <protocols>
        <add name="HttpSoap12" />
        <add name="HttpSoap" />
        <add name="HttpGet" />
        <add name="HttpPost" />
    </protocols>
</webServices>


before

</system.web>

Read more...

20/02/2010

Get The Serial Number Of The Hard Disk

You can prevent the user from entering your application but who has the same serial number by using the following code:





protected void Page_Load(object sender, EventArgs e)
{
lblResult.Text = GetHDDSerialNumber("c");
}

/////////////////////////////////////////
public string GetHDDSerialNumber(string drive)
{
//check to see if the user provided a drive letter
//if not default it to "C"
if (drive == "" || drive == null)
{
drive = "C";
}
//create our ManagementObject, passing it the drive letter to the
//DevideID using WQL
ManagementObject disk = new ManagementObject("win32_logicaldisk.deviceid=\"" + drive + ":\"");
//bind our management object
disk.Get();
//return the serial number
return disk["VolumeSerialNumber"].ToString();
}

Read more...

To know the number of seconds that elapsed since the computer starts

        Int64 SecondsFromStart;

SecondsFromStart = Environment.TickCount / 1000;

lblResult.Text = SecondsFromStart.ToString();

Read more...

Check If The Input Is Numaric Or Not

To check if the input from text box is numaric or not, can we use the following idea:

1- In .aspx page, create TextBox control, and rename it to txtInput.
2- Create Label control, and rename it to lblResult.
3- Create Button control, and rename it to btnCheck.
4- In code behind, write the following code:


    protected void Page_Load(object sender, EventArgs e)
{
if (IsNumeric(txtInput.Text, IsNumericType.Integer))
{
lblResult.Text = "The Input Is Numeric";
}
else
{
lblResult.Text = "The Input Is Not Numeric";
}
}








public enum IsNumericType : int
{
Integer = 0,
Decimal = 1,
Double = 2,
Int64 = 3,
Byte = 4,
Float = 5
}








public static bool IsNumeric(string Input, IsNumericType NumericType)
{
try
{
switch (NumericType)
{
case IsNumericType.Byte:
byte ByteResult = byte.Parse(Input);
return true;
case IsNumericType.Decimal:
decimal DecResult = decimal.Parse(Input);
return true;
case IsNumericType.Double:
double DblResult = double.Parse(Input);
return true;
case IsNumericType.Float:
float FltResult = float.Parse(Input);
return true;
case IsNumericType.Int64:
Int64 I64Result = Int64.Parse(Input);
return true;
case IsNumericType.Integer:
int intResult = int.Parse(Input);
return true;
default:
return false;
}
}
catch { return false; }
}


5- Test it.


Read more...

18/02/2010

Error In facebook


Error in facebook??!!!!!!!! impossible..... but no possible.


Read more...

17/02/2010

Sharepoint Designer Login

If you want from Sharepoint designer ask you about the user name and password every time you open the site, follow the following steps:

1- open IE.

2- From menu choose Tools --> security --> Internet [For Websites outside the network] OR Local internet [For Websites inside the network] --> Custom Level --> User Authentication -->
Logon --> select Prompt for user name and password

3- Click OK

Read more...

TechNet Account

I am now very very happy, because I have free account in TechNet website.
I wish to all get an account like me. :)-

http://technet.microsoft.com/

Read more...

The Defrenet between Viewstate, Session, Application, Cache, and Cookies:

1- Viewstate

Viewstate is a hidden fields in an ASP.NET page, contains state of those controls on a page whose "EnableViewstate" property is "true".

You can also explicitly add values in it, on an ASP.NET page like:


Viewstate.Add( "TotalStudents", "87" );


Viewstate should be used when you want to save a value between diferent roundtrips of a single page as viewstate of a page is not accessible by another page.

Because Viewstate renders with the page, it consumes bandwith, so be careful to use it in applications to be run on low bandwith.



2- Session Variable

Session variables are usually the most commonly used.

When a user visits a site, it's sessions starts and when the user become idle or leave the site, the session ends.

Session variables should be used to save and retrive user specefic information required on multiple pages.

Session variables consumes server memory, so if your may have a huge amount visiters, use session very carefully and instead of put large values in it try to put IDs and references

To add session:

Session.Add("The Name Of Session Variable", The Object Value);


To read the session variable:

Session["The Name Of Session Variable"];


3- Application variables

Application variables are shared variables among all users of a web application

Application variables behave like static variables and they are substitute of static variables as static variables are stateless in web applications

Only shared values should be persisted in Application variables, and as soon as they are not in use they should be removed explicitly.

4- Cache

Cache is probably the least used state feature of ASP.NET.

Cache is basically a resource specific state persistence feature, means unlike session it stick with resource instead of user, for instance: pages, controls etc.

Cache should be used or frequently used pages, controls, and data structures

Data cache can be used to cache frequently used list of values e.g. list of products

5- Cookies

Cookies are some values saved in browsers by the website to retrivbbe and use afterwards.

Usually cookies are used to help dynamic websites to identify visitors and retrieve their saved preferences.

Cookies are also used to facilitate auto login by persisting user id in a cookie save in user's browser.

Because cookies have been saved at client side, they do not create performance issues but may create security issues as they can be hacked from browser.

Finally remember the following points on your finger-tips:

•Viewstate is bandwidth hungry

•Session variables are memory hungry as per number of users

•Applications variables are shared

•Cache is memory hungry as per number of resources

•Cookies are the least secure


Read more...

SQL String Functions Tutorial

1. CHARINDEX string function takes 2 arguments. 1st argument specifies the character whose index is to be retrieved and 2nd argument takes as a string from which character index is carried out.

Example:
Select CHARINDEX ('S','MICROSOFT SQL SERVER 2000')
Result: 6


2. LEFT string function takes 2 arguments. 1st argument takes as a string value and 2nd argument as integer value as length parameter. It returns first characters of specified length starting from the left side of the string entered as 1st argument.

Example:
Select LEFT ('MICROSOFT SQL SERVER 2000',4)
Result: MICR




3. RIGHT string function takes 2 arguments. 1st argument takes as a string value and 2nd argument as integer value as length parameter. It returns last characters of specified length starting from the right side of the string entered as 1st argument.

Example:
Select RIGHT ('MICROSOFT SQL SERVER 2000',4)
Result: 2000


4. LEN string function takes 1 argument as string value and returns the length of entered string.

Example:
Select LEN ('MICROSOFT SQL SERVER 2000')
Result: 25


5. REPLACE string function takes 3 arguments.
1st argument as string value.
2nd argument is a part of string entered as 1st argument which is to be replaced.
3rd argument as a new string value that is to be placed at the place of 2nd argument.

Example:
Select REPLACE ('MICROSOFT SQL SERVER 2000','MICROSOFT','MS')
Result: MS SQL SERVER 2000




6. STUFF string function takes 4 arguments. It is used to replace specified length of characters with provided pattern.
1st argument as string value.
2nd argument as integer value specifying the starting point of characters to be replaced.
3rd arguments as integer value specifying the length of characters.
4th argument as string value specifying the new pattern of characters.

Example:
Select STUFF ('MICROSOFT SQL SERVER 2000', 11, 3,'S.Q.L.')
Result: MICROSFT S.Q.L. SERVER 2000


7. SUBSTRING string function returns the sub string of specified length starting from the entered start position. It takes 3 arguments.
1st argument as string value.
2nd argument as integer specifying the start position.
3rd argument as integer specifying the length

Example:
Select SUBSTRING ('MICROSOFT SQL SERVER 2000', 11, 3)
Result: SQL

8. LOWER string function returns the lower case string whether the entered string has upper case letters. It takes 1 argument as string value.

Example:
select LOWER(‘MICROSOFT ASP .NET WEB HOSTING’)
Result: microsoft asp .net web hosting


9. UPPER string function returns the upper case string whether the entered string has lower case letters. It takes 1 argument as string value.

Example:
select LOWER(‘MICROSOFT ASP .NET WEB HOSTING with SQL Database’)
Result: MICROSOFT ASP .NET WEB HOSTING WITH SQL DATABASE

10. REVERSE string function returns the string in reverse order. It takes 1 argument as string value.

Example:
select REVERSE(‘ASP.NET’)
Result: TEN.PSA




11. LTRIM function returns the string by removing all the blank spaces at left side. It also takes 1 argument as string value.

Example:
select LTRIM (‘ ASP ’)
Result: ASP-----
blanks at the right side not removed.

12. RTRIM function returns the string by removing all the blank spaces at left side. It also takes 1 argument as string value.

Example:
select RTRIM (‘ ASP ’)
Result: -----ASP
blanks at the left side not removed.


13. PATINDEX function returns the position of first occurrence of specified pattern in the provided string. It takes 2 arguments.
1st argument as string value specifying the pattern to match
2nd argument as string value specifying the string to compare.

Example:
select PATINDEX('%RO%','MICROSOFT')
Results: 4


14. STR function returns character data converted from numeric data. It takes 3 arguments.
1st argument as float data
2nd argument as integer value specifying the length of the string including decimal that is to be retrieved.
3rd argument as integer specifying the number of places to the right of the decimal point.

Example:
select STR(140.15, 6, 1)
Result: 140.2


15. ASCII function returns the ASCII code value from the leftmost character specified character expression. It takes 1 argument as string/character expression.

Example:
select ASCII('A')
Result: 65


The Reference:
http://sqlservercodebook.blogspot.com/2008/03/sql-string-functions-tutorial.html


Read more...

Return Random Values From SQL

If you want to retun random values from your table in SQL Server, Use the following query:
SELECT top 4 * FROM dbo.authors
ORDER BY NEWID()

Read more...

Date formatting in SQL Server

Declare @d datetime
select @d = getdate()

select @d as OriginalDate,
convert(varchar,@d,100) as ConvertedDate,
100 as FormatValue,
'mon dd yyyy hh:miAM (or PM)' as OutputFormat
union all
select @d,convert(varchar,@d,101),101,'mm/dd/yy'
union all
select @d,convert(varchar,@d,102),102,'yy.mm.dd'
union all
select @d,convert(varchar,@d,103),103,'dd/mm/yy'
union all
select @d,convert(varchar,@d,104),104,'dd.mm.yy'
union all



select @d,convert(varchar,@d,105),105,'dd-mm-yy'
union all
select @d,convert(varchar,@d,106),106,'dd mon yy'
union all
select @d,convert(varchar,@d,107),107,'Mon dd, yy'
union all
select @d,convert(varchar,@d,108),108,'hh:mm:ss'
union all
select @d,convert(varchar,@d,109),109,'mon dd yyyy hh:mi:ss:mmmAM (or PM)'
union all
select @d,convert(varchar,@d,110),110,'mm-dd-yy'
union all
select @d,convert(varchar,@d,111),111,'yy/mm/dd'
union all
select @d,convert(varchar,@d,112),112,'yymmdd'
union all
select @d,convert(varchar,@d,113),113,'dd mon yyyy hh:mm:ss:mmm(24h)'
union all
select @d,convert(varchar,@d,114),114,'hh:mi:ss:mmm(24h)'
union all
select @d,convert(varchar,@d,120),120,'yyyy-mm-dd hh:mi:ss(24h)'
union all
select @d,convert(varchar,@d,121),121,'yyyy-mm-dd hh:mi:ss.mmm(24h)'
union all
select @d,convert(varchar,@d,126),126,'yyyy-mm-dd Thh:mm:ss:mmm(no spaces)'

Read more...

10/02/2010

Problem with Response.Redirect in Sharepoint

To solve the problem with Response.Redirect in Sharepoint, use the following code:

Response.RedirectLocation = "Put The Target Page URL";

Response.StatusCode = 301;



Read more...

Handle the 404 error in Sharepoint 2007

How to handle the 404 error in sharepoint 2007?
The Sharepoint include default page for 404 error, but we need to change it to our custom page.

So, follow the following steps:




1- Create a new page under your portal, such us: http://www.____.com/pages/FileNotFound.aspx

2- Go to the following path in your server:
\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\LAYOUTS\1025
For arabic,
OR
\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\LAYOUTS\1033
For english.


3- Copy and past the sps404.html file

4- Rename the new file to any friendly name, such us: Mysps404.html

5- Open Mysps404.html file, and modify the following line:
STSNavigate("/_layouts/spsredirect.aspx?oldUrl=" + requestedUrl);

to:
STSNavigate(http://www.____.com/pages/FileNotFound.aspx);


6- Create a console application, to modify the default 404 error page to new page,
write the following lines:



System.Uri webApplicationUri = new Uri("http://www.____.com");

SPWebApplication webApplication = SPWebApplication.Lookup(webApplicationUri);

webApplication.FileNotFoundPage = "Mysps404.html";

webApplication.Update();





7- Run it in your server, and test the scenario.


Read more...