|
What you declare in code behind is only the reference to the control, not the control itself.
---
b { font-weight: normal; }
|
|
|
|
|
Scenario: I was using Template columns with ImageButtons with no problem controlling the columns' width. However template columns are not allowed when 'EnableSortingAndPagingCallbacks="True"'.
Original html code:
<asp:TemplateField ItemStyle-Width="22px">
<ItemTemplate>
<asp:ImageButton ID="imbView" runat="server" ImageUrl="~/Images/ViewSearch.gif" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="22px">
<ItemTemplate>
<asp:ImageButton ID="imgEdit" runat="server" ImageUrl="~/Images/Edit.gif" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="22px">
<ItemTemplate>
<asp:ImageButton ID="imgDelete" runat="server" ImageUrl="~/Images/Delete.gif" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="22px">
<ItemTemplate>
<asp:ImageButton ID="imgPrint" runat="server" ImageUrl="~/Images/Print.gif" />
</ItemTemplate>
</asp:TemplateField> So I replaced the template columns with HyperLinkField. Then in the onRowDataBound event in the code-behind, I set the images to the respective links.
</asp:HyperLinkField DataNavigateUrlFormatString="~/Invoices/Invoice.aspx?id={0}&Readonly" DataNavigateUrlFields="InvoiceID" ItemStyle-Width="20px" />
</asp:HyperLinkField DataNavigateUrlFormatString="~/Invoices/Invoice.aspx?id={0}&Edit" DataNavigateUrlFields="InvoiceID" />
</asp:HyperLinkField DataNavigateUrlFormatString="~/Reports/Reports.aspx?DeleteFromSomeWhere" DataNavigateUrlFields="InvoiceID" />
</asp:HyperLinkField DataNavigateUrlFormatString="~/Reports/Reports.aspx?id={0}" DataNavigateUrlFields="InvoiceID" />
public void dgData_onRowDataBound(Object src, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRowView row = (DataRowView)e.Row.DataItem;
HyperLink link = (HyperLink)e.Row.Cells[0].Controls[0];
if (!(link == null))
{
link.ImageUrl = "~/Images/ViewSearch.gif";
link.ToolTip = "Print";
}
link = (HyperLink)e.Row.Cells[1].Controls[0];
if (!(link == null))
{
link.ImageUrl = "~/Images/Edit.gif";
link.ToolTip = "Print";
}
link = (HyperLink)e.Row.Cells[2].Controls[0];
if (!(link == null))
{
link.ImageUrl = "~/Images/Delete.gif";
link.ToolTip = "Delete Invoice";
link.Attributes.Add("onclick", "javascript: alert('works'); return false;");
}
link = (HyperLink)e.Row.Cells[3].Controls[0];
if (!(link == null))
{
link.ImageUrl = "~/Images/Print.gif";
link.ToolTip = "Print Invoice";
}
}
}
After the changes, which fixes the EnableSortingAndPagingCallbacks problems, the column images (ViewSearch, Edit, Delete & Print) are spaced apart instead of nicely next to each other. I have tried the following variations with no luck.
if (!(link==null))
{
link.ImageUrl = "~/Images/ViewSearch.gif";
link.ToolTip="Print";
link.Width = System.Web.UI.WebControls.Unit.Pixel(20);
e.Row.Cells[0].Style.Add("max-width", "20px");
e.Row.Cells[0].Style.Add(System.Web.UI.HtmlTextWriterStyle.Width, "20px");
e.Row.Cells[0].Width = System.Web.UI.WebControls.Unit.Pixel(20);
}
and also
<asp:HyperLinkField ... ItemStyle-Width="20px" ControlStyle-Width="20px"/>
Thanks in advance,
Michael
I firmly believe that any man's finest hour, the greatest fulfillment of all that he holds dear, is that moment when he has worked his heart out in a good cause and lies exhausted on the field of battle - victorious.
Vince Lombardi (1913-1970)
-- modified at 17:18 Thursday 29th June, 2006
|
|
|
|
|
Hi Michael,
There are a couple of ways which you can try:
+ Use Atlas with your GridView control, you can keep using the TemplateField and simply place the GridView control inside the UpdatePanel to support client callback with paging and sorting.
+ Use the ButtonField with ButtonType="Image" :
<asp:ButtonField ItemStyle-Width="22px" ButtonType="Image" ImageUrl="..." />
+ Use the BoundField with adding the ImageButton to the column in the RowDataBound event handler:
<asp:BoundField ItemStyle-Width="22px" />
|
|
|
|
|
I ended up going with the Atlas:UpdatePanel.
Thanks!
I firmly believe that any man's finest hour, the greatest fulfillment of all that he holds dear, is that moment when he has worked his heart out in a good cause and lies exhausted on the field of battle - victorious.
Vince Lombardi (1913-1970)
|
|
|
|
|
Hi all
I am trying to on mouseover display name and put it in session (IN HTML PAGE)
MYCODE
--------
shape=RECT coords=228,232,441,279 href=hs22.aspx>
------------------
Can any one tell me how can i put the value in session
THX
asdfasdfasdfasdfasdfasdfasdfasdfasdfasdf
-- modified at 15:05 Thursday 29th June, 2006
|
|
|
|
|
You can't access the Session object from client script. You have to send the value to the server, so that the server code can put it in the session variable.
---
b { font-weight: normal; }
|
|
|
|
|
You may consider using AJAX to send a request to the server to persist the value in the Session object.
|
|
|
|
|
Hi,
I am Ravindra,currently doing a web application
consisting of :
1.Login.aspx
2.Mails.aspx
and other web forms
when I type the url : http\\localhost\Mails.aspx ,it is directly opening that web page
without displaying Login.aspx web page.
I want to restrict the mails.aspx page until the user logins with Login.aspx,
and also mails.aspx page is to be restricted even the user types the
url(http\\localhost\Mails.aspx)
please help me ,I am new to ASP.net.
ravindra donkada
|
|
|
|
|
Simple Forms Authentication
Basically, you need to configure forms authentication and set access rules on different pages or directories to tell the server which pages are registricted.
-- modified at 15:41 Thursday 29th June, 2006
LINK: Made link
|
|
|
|
|
Simply assign some value to a session variable in login Page say..
Session("login")="admin"
And on Mail.aspx page check
If Session("login")="" then
Response.redirect("login.aspx")
else
Your page code here
end if
Lets work it Out.........!
|
|
|
|
|
Hello,
I am using FormsAuthentication and Membership in ASP.NET 2.0 Applicaion. On Login page I have a link to page saying, Forgot password. On click of this link it should lead me to ForgotPassword.aspx page. The problem is, everytime I click on this link, system takes me back to Login page. To reach to that page I have to be logged in, which is not the requirement.
Had anyone have idea, how to mitigate this problem.
Thanks in advance.
- ashish
|
|
|
|
|
Move that page out of the protected area. Or use could use the admin tool to set the access rules on it, or you may be able to do it in Web.config in <location> tags, but I'm not sure if that will work with the Membership stuff.
|
|
|
|
|
Like eggsovereasy said, you can use the
location[^] tag to configure the authorization which allows all users to access this page. You can find the sample settings from the link.
|
|
|
|
|
I want to check whether gridview contain any row so that if grid view is empty i can print appropriate message.
Note that gridview1.rows.count doesn't work.
aLi
|
|
|
|
|
Try setting the EmptyDataText property on the gridview. It is a message to display if the gridview is empty.
|
|
|
|
|
With the GridView control, you can use EmptyDataText or EmptyDataTemplate to display your message or whatever you want when the datasource is empty.
GridView Members[^]Last modified: Thursday, June 29, 2006 10:12:40 PM --
|
|
|
|
|
I have a Content Page with a Custom Content Place holder. How do I get my functions that do various calculations in the code behind page to show up in the Custom Content Area at runtime? Thanks.
|
|
|
|
|
Perhaps, I don't undertand what you mean with your Custom Content Place holder and Custom Content Area, but basically you can place a container in the content area and in code-behind you can call your functions to populate and assign the values to the container. More details could help.
|
|
|
|
|
Hi
Can any one tell me where i can get a koool but free shoping cart in ASP.net.
Note: i am using VB.net
Thanks in advance
Lets work it Out.........!
|
|
|
|
|
|
Hi all,
Very much confuse with this.
I have a datagrid, and i am able to pass the value to javascript function through "onclick" event as below:
e.item.attributes.add("onclick","javascript:myfunction('"+value1+"');");
but, when i am trying to pass the value of the first row on datagrid through "onload" event as below:
dg.Items[0].Attributes.Add("onload","javascript:myfunction('"+value1+"');");
it's not passing the value.
I have to use onload event, so i can display default value th' javascript function.
Any help will be appreciated.
Thanks,
NIKI
|
|
|
|
|
Make sure that you run this code after the datasource is bound to the grid control. Also, you can keep using the ItemDataBound event handler, but you can detect the first row so that you only run your code with this row.
|
|
|
|
|
I am using a HttpHandler (the ASP.NET 1.1 DynamicImage control from MSDN --
http://msdn.microsoft.com/msdnmag/issues/04/04/CuttingEdge/
My project structure is like i have one project of Controls and one web application and one DAL in my project.
I have placed the DynamicImage.cs and CachedImageService.cs in the controls project.
It is mentioned in the site that a setting has to be made in web.config file also which is something like this:
"<httpHandlers>
<add verb="GET"
path="cachedimageservice.axd"
type="MsdnMag.CachedImageService,DynamicImage" />
</httpHandlers>"
But i am unable to add the same in web.config, it gives some rutime error.
The assemble name for both the files have been changed say deepak.controls
And for what is axd file used.
If anyone has any ideas I'd love to hear them.
Thanks!
Deepak Surana
|
|
|
|
|
|
thanks a ton. that link solved the problem.
|
|
|
|