|
I am working on an ASP.NET 2.0 project using visual studio 2005.
The problem I have is that everytime that I precompile the project and publish it, all the binaries get a new random filenames and the aspx files are updated accordingly. Even using the option "Use fixed naming and sigle page assemblies", it generates a single binary file for every aspx file, but it has some random digits at the end of it.
This is a problem if there are design changes in the already published previous version because I have to manually change the header of it.
Is there any way to force the publisher tool to generate binary files without this random naming?
Thanks a lot for your help
|
|
|
|
|
Use a web Deployement project if you don't have nested webs. Also if you Publish Web vs. Copy Web you won't mind that the files are named when they are published. You just have to re-deploy the site when you change something but MSBuild will change the headers for you.
|
|
|
|
|
Hi,
I've been trying to format some fields as Decimal numbers but not as currency. The other numeric formats work great (currency, scientific notation, etc.) and the "D" works fine with Dates. The "D" will not work for me on a numeric field though. I've tried both embedding in the DataBinder statement:
<%# DataBinder.Eval(Container, "DataItem.AmountPaid", "{0:D2}") %>
and as a DataFormatString:
DataFormatString="{0:D2}"
I've also tried the ItemDataBound event. No luck.
Any suggestions?
Will
|
|
|
|
|
Are you just trying to display two decimal places? If so, use the F format specifier:
Decimal pi = new Decimal (Math.PI);<br />
Console.WriteLine ("{0:F2}", pi);
|
|
|
|
|
Thanks! That's doing it for me. I ignored the "F" because description in the MSDN doc is pretty vague (fixed) . . . until you follow the chain to the "Standard Numeric Format Strings". I just didn't go far enough the first time. I also see there that the "D" only works with integral types as the other poster suggested. I'm not sure what type results from the DataBinder statement? Evidently it's not a String or Decimal. Thanks again.
|
|
|
|
|
What is the data type of the field? The "D" specifier will only work with integral types.
---
b { font-weight: normal; }
|
|
|
|
|
I'm not sure what type results from the DataBinder statement? Evidently it's not a String or Decimal. But, I see what you mean now that I found "Standard Numeric Format Strings" item in the MSDN doc. I circumvented the issue by using the Fixed format instead. Some time when I'm not under the gun I'll have to follow up and figure this one out. Thanks.
|
|
|
|
|
The DataBinder returns a value of the type Object, but the real type of the value depends on the data type of the source. If you for example have a int field in the data base, the object contains an Int32 value.
---
b { font-weight: normal; }
|
|
|
|
|
Hello There!
I have a usercontrol named A that displays data from a database. I create a dynamic number of usercontrols depending on the number of hits from the database given a certain critera. If I receive 4 datasets from the database I create 4 usercontrols and so on…
These Usercontrols contains repeater objects displaying the data aswell as a button that interact with the data. Im now experiencing some major problems to get these buttons to fire once pressed.
I do believe I have done it the right way.
Usercontrol A
1. Initialize
2. declare Click method
<br />
private void InitializeComponent()<br />
{<br />
this.OpenButton.Click += new System.EventHandler(this.Open_Click);<br />
this.Load += new System.EventHandler(this.Page_Load);<br />
}
protected void OpenButton_Click(object sender, System.EventArgs e)<br />
{<br />
}
It works perfect using static usercontrols, but not in this dynamic case. It wont even enter the OpenButton_click method in debug mode.
Is the EventHandler passing the event to the main app or what is happening.?!? Nothing what so ever happens..
Please help me Experts-Number-One, you are my only hope….
/Peter
|
|
|
|
|
See,
Recall that the framework create the controls tree only for static controls - this is why the event of the dynamic controls could not reached there targets when the page is posted back - so this is your job, as i describe in a minute.
The problem is that the page controls tree is built before the page load - and events that should be fired target to controls resolved in that stage. Hence if your dynamic controls are not existed in this level - WITH THE SAME ID AS THEY HAD IN THE PREVIOUS POSTBACK - the events will not be fired.
So, a good solution will be:
1 - When you create the controls assigned them a unique id. Aparantly you will do it in the Page_Load, you should do it only if the page was not post bask. Dont forget to add you controls to the Controls Collection of their container. For example - if you add these controls directly on the form - Write: Page.Controls.Add(...your control here).
Page_load...
- if not post back
- Create the control
- Assigned the created control a unique id
- Add the created control to its container "Controls" collection.
2 - When you create these controls - put some information in the ViewState so you can rebuild these controls when the page will be posted-back:
- ViewState[some key]=information.
The information should be encoded in a way that can describe you in the next step what controls were existed before the post back.
3 - Override the TrackViewState method of the page and rebuild the dynamic part of your page using the information you saved in the ViewState. Again dont forget to add these dynamic created controls to your Controls collection.
That is all!
If the dynamic controls that you are creating are always the same (obviously they are not) you could be satisfied with the Page_Load part without checking the PostBack status.
Best regards,
e-laj
|
|
|
|
|
Good comment. I have not tried yet but it give me alot information.
Thanks so much.
|
|
|
|
|
Thanks for the reply and detailed answer e-laj!
I have been away for a couple of days so I havn't been able to reply until now. Anyway I have made some progress:
1. I load the controls in Page_Load and assign them unique ids within
not PagePostBack.
2. I put the control into the viewstate (to load when page is post back)
The events wont fire the first time but the second time they do.
It still seems to be something wiht the lifecycle.
Could you explain some more about the TrackViewState?
<br />
if(!Page.IsPostBack) <br />
{<br />
<br />
RequestDataFromPostMessage();<br />
<br />
Domain [] domainCollection = GetInformationFromWebSevice()<br />
<br />
<br />
domains=domainCollection.Length;<br />
ViewState["domains"]=domains;<br />
DomainControls = new DomainControl[domains];<br />
<br />
for(int i=0;i domains;i++) <br />
{<br />
DomainControls[i]=(DomainControl)LoadControl "DomainControl.ascx");<br />
<br />
<br />
DomainControls[i].InitSubDomainData(.......);<br />
<br />
<br />
DomainControls[i].ID=i.ToString();<br />
Session["DomainControl"+i.ToString()]=(Control)DomainControls[i];<br />
placeHolder1.Controls.Add(DomainControls[i]);<br />
<br />
<br />
}<br />
}<br />
<br />
<br />
else <br />
{<br />
domains = (int)ViewState["domains"];<br />
DomainControl dControl = new DomainControl();<br />
for(int i=0;i<domains;i++) <br />
{<br />
dControl = (DomainControl)Session["DomainControl"+i.ToString()];<br />
placeHolder1.Controls.Add(dControl); <br />
}<br />
<br />
}<br />
The debugger crahses in the Onclick event method in the usercontrol while debugging.
protected void Open_Click(object sender, System.EventArgs e) {<br />
....do something<br />
}<br />
Any suggestions?
Thanks!
|
|
|
|
|
Sorry - I have a little mistake, well i implement dynamic control creation long time ago - i forgot an important point.
You should override the LoadViewState instead of TrackViewState.
The TrackViewState is executed before the view state is populated with the previous value, LoadViewState is the right point to initialize dynamic controls according to view state values - in this point the view state has its previous values.
Here is a full running example. In this example you can create dynamic buttons and executes their events.
I wrote this example for you and any other who may need it.
The DynamicExample.aspx
=======================
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DynamicExample.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="buttonCreateButtons" runat="server" OnClick="buttonCreateButtons_Click" Text="Create" /> <asp:TextBox ID="textBoxTotalButtons" runat="server" Width="53px"></asp:TextBox> buttons<br />
<br />
<asp:Panel ID="panelButtons" runat="server" Height="85px" Width="319px">
</asp:Panel>
<br />
Click Message:<br />
<asp:Label ID="labelClickMessage" runat="server" BackColor="#80FF80" Height="25px" Width="325px"></asp:Label><br />
<br />
Command Message:<br />
<asp:Label ID="labelCommandMessage" runat="server" Height="25px" Width="325px" BackColor="#80FF80"></asp:Label><br />
<br />
</div>
</form>
</body>
</html>
The DynamicExample.aspx.cs
==========================
/*******************************************************************************
*
* Filename: DynamicExample.cs
*
* Class: DynamicExample
*
* Creation Date: 06/Oct/2006
*
* Update list:
* -----------
* 1) Date:
* Description:
*
* Writer: Ilan Amoyal (e-laj)
*
******************************************************************************/
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
/// <summary>
/// Loads the view state - and initializes dynamic controls according to the view state.
/// </summary>
/// <param name="savedState">The saved state.</param>
protected override void LoadViewState(object savedState)
{
/* Call the base calss implementation */
base.LoadViewState(savedState);
/* Create any dynamic */
/* Recall the int? is .NET 2 nulleable integer */
int? totalButtons = (int?)ViewState["totalDynamicButtons"];
if(totalButtons != null)
{
CreateDynamicButtons((int)totalButtons);
}
}
/// <summary>
/// Creates dynamic buttons.
/// </summary>
/// <param name="totalButtonToBeCreated">The total number of buttons to be created.</param>
private void CreateDynamicButtons(int totalButtonToBeCreated)
{
/* Removes any previous buttons */
panelButtons.Controls.Clear();
for(int i = 1; i <= totalButtonToBeCreated; i++)
{
CreateDynamicButton(i);
}
/* Save the number of buttons that were created. */
ViewState["totalDynamicButtons"] = totalButtonToBeCreated;
}
/// <summary>
/// Creates a button and adds ot to the panel controls collection.
/// </summary>
/// <param name="i">The ordinal position of this button.</param>
private void CreateDynamicButton(int i)
{
Button btn = new Button();
btn.ID = CreateButtonUniqueId(i);
/* Attaches events */
btn.Click += new EventHandler(btn_Click);
btn.CommandArgument = "This is button no " + i.ToString();
btn.Command += new CommandEventHandler(btn_Command);
btn.Text = "Button no " + i.ToString();
/* Adds the button to its container "Controls* collection. */
panelButtons.Controls.Add(btn);
/* If we have specific information related to this button that we wish to access
* on each post-back we can add this information to the view state.
*
* ViewState["some_unique_key"] = some_unique_info;
*/
}
/// <summary>
/// This function creates a uniques id according to the passed integer.
/// </summary>
/// <param name="ordinal">The integer related to the dynamic button.</param>
/// <returns>A unique id for that button.</returns>
private string CreateButtonUniqueId(int ordinal)
{
return "dynamic_button_no_" + ordinal.ToString().Trim();
}
/// <summary>
/// Here we create dynamic buttons according to the number assigned to the text box.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
protected void buttonCreateButtons_Click(object sender, EventArgs e)
{
int totalButtonToBeCreated;
if(int.TryParse(textBoxTotalButtons.Text, out totalButtonToBeCreated))
{
CreateDynamicButtons(totalButtonToBeCreated);
}
}
/// <summary>
/// Here is an implementation of the dynamic controls events.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.Web.UI.WebControls.CommandEventArgs"/> instance containing the event data.</param>
void btn_Command(object sender, CommandEventArgs e)
{
labelCommandMessage.Text = (string)e.CommandArgument;
}
/// <summary>
/// Handles the Click event of the dynaic buttons.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
void btn_Click(object sender, EventArgs e)
{
/* Do what ever you want to. For example: */
Button btn = (Button)sender;
labelClickMessage.Text = btn.ID + " pressed!";
}
}
================
Have a nice day!
================
|
|
|
|
|
I have a gridview control and When i click on the headers to sort the column of the grid the dataset is getting refreshed. And when i move on to the next page the sort order is not maintained. So how do i stop the dataset from reloading when i moveon to the next page??
|
|
|
|
|
you just need to re-bind the datasource using the sorted data to your gridview control when headers are clicked.
|
|
|
|
|
Hi Nice People,
I have a table with a of rows of number links and another of Infragistic UltraWebTab control. How can I add html kind of anchor links in Infragistic UltraWebTab? Or how can I have my the starting links set in my first but have the anchor set in the Infragistic UltraWebTab in my another ?
Thanks much!
|
|
|
|
|
You might find more help for this on the infragistics newsgroups at their site.
|
|
|
|
|
I have a "Search" form with two buttons and a bunch of textboxes. The first button is a "Logout" button while the 2nd button is a "Search" button (I named it btnSearch).
If the user enters text into any textbox and then clicks enter, the logout button is accessed instead of the Search button meaning the only way to search is for the user to manually click the Search button.
I've tried using code such as "btnSearch.Focus();" & setting the defaultfocus property to "btnSearch" in my "form" tag, however neither has worked.
So how can I set my page so the user accesses the Search button when they click "Enter"?
Thanks in advance.
-Goalie35
|
|
|
|
|
Read my reply to the post below.
how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things
--thedailywtf 3/21/06
|
|
|
|
|
Hi,
I am Ravindra,presently doing a project in asp.net.
The Login page of my Web Project consists of two Buttons.
If user enters his username and password and clicks on enter button of keyboard,
the Signin button is to be submitted not the other button.
So,please specify how to get focus on the specified Button
Thanks in advance.
Ravindra
|
|
|
|
|
Javascript can be used.
With Regards
Satips
|
|
|
|
|
put the script below in your page.
function ButtonPress (evt, btnID)
{
if (evt.keyCode == "13")
{evt.returnValue= false ; evt.cancel= true ; document.getElementById(btnID).click(); return false; }
}
//the code behind should have
this.txtPassword.Attributes.Add("onKeyPress", @"ButtonPress(event, '" + @this.ButtonSignin.ClientID + @"')");
//this code will cause the button click event when the user presses enter and the textbox has the focus. Basically you can set a default button for each textbox
how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things
--thedailywtf 3/21/06
|
|
|
|
|
Try using tabindex properties of the controls..
set tabindex to 1 for username
2 for password
3 for the button u want to click..
hope this will help u solve ur problem...
|
|
|
|
|
at page load event i used seesion variable to insalize lable control which is present on master page. it work perfectly on all web page who inherite master page accept one web page.
page laod, page preload, preinint, PreRender any of the above event not fired when i load my webpage. even they can't show message by
response.write();
please provide help.
deepak
|
|
|
|
|
You probably have AutoEventWireup set to false for that page.
Either change that to true or hook up your event handlers by hand.
--------------------------------------------------------
My portfolio & development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|