Thursday, March 29, 2012

How to Get Parent Url in .Net...


   System.Uri url = Context.Request.UrlReferrer;
   string referringURL = url.AbsoluteUri.ToString();
   lbltest.Text = referringURL;



How to get Browser Page Url if Pages have used with url rewriting....

string s= Request.Url.GetLeftPart(UriPartial.Authority)+Request.RawUrl;

Wednesday, March 21, 2012

Generate Proxy class of wcf and webservice....

Open the visual studio command prompt with administrator rights and Select the Drive where you want to store..and then type
For example your wcf service is hosted on http://localhost/TestService/Achievementmaster.svc Then you can write like this

D:\>svcutil.exe http://localhost/TestService/Achievementmaster.svc?wsdl/out:proxy1.cs

Then You can see the generated proxy class in D drive.......


Now if you want to generate proxy class for webservice then


D:\>wsdl /language:c# /out:d:\myProxyClass.cs http://localhost/WebService/Service1.asmx?WSDL


where you can also write vb in language if you want to generate in vb code



Use Of Proxy Class..............
Introduction
                 we can generate the proxy class of WCF service or web service.As I discussed How to generate proxy class in above discussion and How to create a webservice in http://aspdotnetbank-kartik.blogspot.in/2012/05/how-to-create-webservice-and-how-can-we.html

                 For Webservice and WCF service we need to add the reference in our project.but by using the Proxy class we dont need to add the reference in our Project.By just discussed as above generate the Proxy class of it.Then add that class in your project and then after we can use it same as we use in by adding the reference of it.

                Hope this will help you in future.................
              

Change Background-color of Div after Clik on LinkButton in Repeater..

Lets take an Example

 <asp:Repeater ID="rptCategory" runat="server">
 <HeaderTemplate>
           <h2  style="margin-bottom: 5px; color: #008752!important;font-size:16pt;">
                                                Course Categories</h2>
 </HeaderTemplate>
 <ItemTemplate>
           <table cellpadding="2px" cellspacing="2px">
           <tr>
                 <td>
                 <div runat="server" id="divleft" onmouseover="this.style.background='#BADFCE';" onmouseout="this.style.background='white';">
                   <asp:LinkButton ID="lnkCategory" runat="server" Text='<%#Eval("CategoryDescription")%>'
                   CommandArgument='<%# Eval("CourseLibraryCategoryID") %>' OnClick="lnkCategory_Click">
                    </asp:LinkButton>
                    </div>
                    </td>
            </tr>
            </table>
            </ItemTemplate>
            <FooterTemplate>
            </FooterTemplate>
 </asp:Repeater>


Answer:


 protected void lnkCategory_Click(object sender, EventArgs e)
  {
          
           //This is the code For Removing all style of Repeater Item
            foreach (RepeaterItem item in rptCategory.Items)
            {
              
                LinkButton previous = item.FindControl("lnkCategory") as LinkButton;
              
                (previous.NamingContainer.FindControl("divleft") as System.Web.UI.HtmlControls.HtmlContainerControl).Attributes.Remove("style");
                previous.Attributes.Remove("style");
            
              
            }
            LinkButton temp = (sender as LinkButton);
            temp.Attributes.Add("style", "color:green  !important;");
            (temp.NamingContainer.FindControl("divleft") as System.Web.UI.HtmlControls.HtmlContainerControl).Attributes.Add("style", "background-color:#BADFCE !important;");
}

Thursday, March 1, 2012

The select permission was denied on the object database schema 'dbo.office'


Use 'Database Name'
Go
GRANT SELECT
ON 'Table Name'

TO public
GO 


For Example:
USE master
GO
GRANT SELECT
ON Office
TO public
GO