|
check this out it shows how to bind to a radiobuttonlist which is basically the same as binding to a dropdown
http://www.w3schools.com/aspnet/aspnet_xml.asp
|
|
|
|
|
Hi,
I am redirecting my page with query string (UserId is passed as query string). User 'A' has the rights to access the new page. He enterred into that page and he does access. UserId of 'A' is passed as query string. He do not change the query string at the address bar. Now, 'A' can access the page by giving other User's Id after entering into this page. I want to make that address bar as read only after loading this page.
Is it possible?.
By mean time, I am checking the user id in the page load itself, if it false, I am redirecting into main page. Pls help.
Balasubramanian K.
|
|
|
|
|
You cant make the url bar read only, you could hide it and open a new window without it showing but the user can still find a way to by pass this. Best to not show the query string at all in the URL and to hide it instead.
There are lots of articles on hiding query string values when trasnferring them via url
|
|
|
|
|
Thank you for your reply.
Balasubramanian K.
|
|
|
|
|
How to hide the query string? I've read that this is the main disadvantage of qry string. Otherwise, Qry string should be encrypted and decrypted. I dont have any other idea. If u know that how to hide or If you have any articles link, Pls send me...tnx in adv.
Balasubramanian K.
|
|
|
|
|
If the information you are hiding is sensitive then its best to just use sessions
|
|
|
|
|
BalasubramanianK wrote: Now, 'A' can access the page by giving other User's Id after entering into this page. I want to make that address bar as read only after loading this page.
You can't make the address bar read only as ASP.NET don't have any control over the programs installed on the client machine. Your best bet is to validate the query string before processing.
I assume you are keeping currently logged in users id in session named "id". So in the page load check current user is authorized to see this page, something like
if(Session["id"] != NULL && Session["id"].ToString() != Request.QueryString["id"])
{
Response.Redirect("NotAuthorized.aspx");
} The above code will redirect to "NotAuthorized.aspx" if the id passed is not the current user. So user "A" can't pass some other id to see their details.
If you have many pages like this, I would prefer to create a base class and derive all your pages from it. So the checking can be automated.
|
|
|
|
|
i am working on Active director multiple domain for search user.but Its produced Error:- There is no such object on the server. -2147016656
Please Help me.
Code:-
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
FindUser("dev\t", True)
End Sub
Public Function FindUser(ByVal principalname As String, ByVal useGC As Boolean) As DirectoryEntry
Try
Dim searchRoot As DirectoryEntry
Dim searcher As DirectorySearcher
Dim name() As String
Dim ncName As String
name = principalname.Split("\")
If name.Length <> 2 Then
Throw New ArgumentException("principalname is not in the correct format", principalname)
End If
ncName = ResolveNetBiosNameToDN(name(0))
searchRoot = GetDirectoryEnTry(ncName, useGC)
searcher = New DirectorySearcher(searchRoot, String.Format("(&(objectCategory=person)?(objectClass=user)? (sAMAccountName={0}))", name(1)), New String() {"distinguishedName"}, SearchScope.Subtree)
Try
Return searcher.FindOne().GetDirectoryEntry()
Catch ex As NullReferenceException
Throw New ArgumentException("The given username was not found", "principalname", ex)
End Try
Catch ex As Exception
End Try
End Function
Private Function ResolveNetBiosNameToDN(ByVal netbiosName As String) As String
Try
Dim authenticationType As New System.DirectoryServices.AuthenticationTypes
If ConfigurationManager.AppSettings("AD_UseSecureConnection").ToUpper.Trim.Equals("TRUE") Then
authenticationType = AuthenticationTypes.Secure
Else
authenticationType = AuthenticationTypes.None
End If
Dim rootDSE As New DirectoryEntry(ConfigurationManager.AppSettings("AD_IP").Trim, ConfigurationManager.AppSettings("AD_UserName").Trim, ConfigurationManager.AppSettings("AD_Password").Trim, authenticationType)
' Dim configurationNamingContext As String = CType(rootDSE.Properties("configurationNamingContext").Value, String)
Dim defaultNamingContext As String = CType(rootDSE.Properties("distinguishedName").Value, String)
'defaultNamingContext = defaultNamingContext.Split(",")(0)
' Dim Str As String =
Return CType(GetDirectoryEnTry(String.Format("CN={0}, CN=Partitions, {1}", netbiosName, defaultNamingContext)).Properties("nCName").Value, String)
' Return DirectCast(GetDirectoryEnTry(String.Format("CN={0}, CN=Partitions, {1}", netbiosName, DirectCast(configurationNamingContext.Properties("distinguishedName").Value, String))).Properties("nCName").Value, String)
'Dim ss As String = "sada"
Catch ex As System.Runtime.InteropServices.COMException
If CInt(ex.ErrorCode) = 2147950640 Then
Throw New ArgumentException("The given netbios name was invalid", "netbiosName", ex)
Else
Throw
End If
Catch ex As Exception
' return (string) GetDirectoryEntry(string.Format("CN={0}, CN=Partitions, {1}", netbiosName, (string) ConfigurationNamingContext.Properties["distinguishedName"].Value)).Properties["nCName"].Value;
End Try
End Function
Public Function GetDirectoryEnTry(ByVal distinguishedName As String) As DirectoryEntry
Return GetDirectoryEnTry(distinguishedName, False)
End Function
Public Function GetDirectoryEntry(ByVal distinguishedName As String, ByVal useGC As Boolean) As DirectoryEntry
Try
Dim path As String
path = IIf((useGC), "GC://", "LDAP://")
Dim _server As String = "dev.eventure.biz"
If _server IsNot Nothing Then
path += _server
End If
If (Not path.EndsWith("/")) AndAlso (distinguishedName <> "") Then
path += "/"
End If
path += distinguishedName
If path.EndsWith("//") Then
path = path.Remove(path.Length - 2, 2)
End If
Return New DirectoryEntry(path, "dev\adadmin", "password_1234", AuthenticationTypes.Secure)
Catch ex As Exception
End Try
End Function
Thanks
Piyush Vardhan Singh
p_vardhan14@rediffmail.com
http://holyschoolofvaranasi.blogspot.com
http://holytravelsofvaranasi.blogspot.com
|
|
|
|
|
I have a gridview that has some prices that is dispayed as strings.
In the database these prices are nvarchar datatype.
I need to sort them in the gridview as numbers because they are not sorted correctly as strings but at the moment I can't change this datatype in the database. So is there any workaround to sort this column as numbers? how?
|
|
|
|
|
Wouldn't you just convert the string to an int, if so Convert.ToInt32...something like that maybe
|
|
|
|
|
how can I do that?
do I have to do it inside the sorting event??
How..details plz.
thanks
|
|
|
|
|
Try sherin's suggestion below first to see if that helps you, if not convert string to int
|
|
|
|
|
Put it around your value e.g. Convert.ToInt32(value in here)
|
|
|
|
|
Convert your price field to integer in the query...
SELECT Your_Fields FROM Your_Table WHERE Your_Condition ORDER BY CAST(Your_Field AS INT)
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|
|
The problem is that I'm using the SortExpression property of the gridview's databound item. The sortExpression property only takes that column name to be sorted so how can I add this Cast(field As Int)??
|
|
|
|
|
Try casting in your select
select column1, column2,CAST(columnn3 AS INT) as column3 from table
This will return an int column to your grid, problem solved.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|
|
Got It
CAST In Your Select Sql Query
Select field1,CAST(Price AS INT) As Price,.......
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|
|
Thanks a lot, I think this is gonna work.
|
|
|
|
|
Thats what I said - do the cast in the query, it then returns the correct datatype.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Your design is broken. Why you need to keep prices in NVarchar field ? How are you binding this grid view ? Using a DataTable ? If yes, after filling the data table, change the column type to integer or double. So gridview can sort it correctly.
|
|
|
|
|
I need to know how can I bind my gridview from a pop up window?
I have a gridview on a parent page and then a user can open a pop up window to perform some changes on the gridview in the parent page after that he closes the window. Right then I need to bind the gridview on the parent page to view the changes that the user did from the pop up window.
How can I do that?
|
|
|
|
|
OK so you want the following to happen:
User views gridview in mainpage
user edit gridview in new window
user views gridview in mainpage with updated values.
The thing is when the new window closes its not very easy to navigate a user back to the mainpage and then refresh that page to reflect the new changes.
Instead of opening a new window(which may be blocked by pop-up blocker) keep them in the same window and user query string to transfer the values.
|
|
|
|
|
thanks for the repy, but there is no way I can do all the editing on the same page. The only way is to use a pop up window.
Is there any other solution for this?
|
|
|
|
|
No, because as soon as you open a pop-up window your application is split in two and they can now continue navigating around the mainpage even with the pop-up open.
best to keep it all in the same window anyway
|
|
|
|