I am using Reportviewer control in my .aspx page. I set
ReportViewer1.ShowPrintButton = false;
but it didn't work. Not only this button, i tried to show refresh button but it didn't work. thanks.
protected void Page_Load(object sender, EventArgs e) {
if (!this.IsPostBack)
PrintReport();
}
private void PrintReport() {
ReportViewer1.ShowPrintButton = false;
ReportViewer1.ShowRefreshButton = false;
}
You need to be running reports in remote mode in order for the buttons to work. In addition, if you want them to be shown, you have to set the values to True, not False as is shown in your code.
If you are running in local mode, there is an ActiveX control that can be downloaded, but this will only work for IE.
Here is a link to the MSDN documentation about printing from ReportViewer that should help you out.
Related
I can't believe that disabling specific tabpages (visible but greyed out that means not clickable) is not possible in Visual Studio C# Form app. I have found just a workaround that I couldn't bring to work.(See link below)
I wanted to ask this question again, because perhaps there is another solution/workaround in the meantime.
How to highlight/grey-out Tabcontrol Tabpage
For just making the tab nonclickable (what is also OK for me) I have used this code, but not working
private void tabControl1_Selecting(object sender,TabControlCancelEventArgs e)
{
if (!e.TabPage.Enabled)
{
e.Cancel = true;
}
}
For example if you want to disable tabPage2 use this code in form load event. It will not show in intellisense but you can type.
tabPage2.Enabled = false;
Then use tab control selecting event like this
private void tabControl1_Selecting(object sender, TabControlCancelEventArgs e)
{
if (e.TabPageIndex < 0) return;
e.Cancel = !e.TabPage.Enabled;
}
I am using webbrowser into Windows application.
When webbrowser navigate first time, there is no problem.
But calling second time webbrowser navigate captcha does not change.
private void button1_Click(object sender, EventArgs e)
{
webBrowser1.Navigate("uyg.sgk.gov.tr/SgkTescil4a");
webBrowser1.ScriptErrorsSuppressed = true;
webBrowser1.AllowNavigation = true;
}
To prevent page caching on your client, which may be the reason why you see the Captcha not changing use
webbrowser1.Refresh(WebBrowserRefreshOption.Completely).
to clear the cache. If its not a client side caching issue, then its a problem with the website.
I am working at a problem in ASP.NET.
I have to create 2 windows (i think that I need to make web forms, i don't know why they said windows) one is the login form, when i press ok and the username and password is ok, I need to
show my second window (webform)
How can I do that?
I tried to do
protected void Button1_Click(object sender, EventArgs e)
{
Form2 form = new Form2();
form.SetFocus("id");
}
But it gives me error
A form tag with runat=server must exist on the Page to use SetFocus() or the Focus property.
What should I do?
Am i right, I have to do separate webforms for thoose windows?
This is the picture from the problem that they provided
If you use webforms you can just use the following code to redirect to second form:
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("Webform2.aspx");
}
I have this button event:
protected void AddDetails_Click(object sender, EventArgs e)
{
DataSetTableAdapters.SelectFriendsTableAdapter sft = new DataSetTableAdapters.SelectFriendsTableAdapter();
try
{
sft.AddFriend(current, newFriend, false);
}
catch
{
error.Text = "Something happened. Bummer!";
}
}
in the try section, I'm adding entries in the Database. In the page there are Labels / Textboxes with the corresponding values.
Everything works fine. However, I need to refresh the page in order to see the changes after I click on this submit button.
I have added if(!IsPostBack) at the beginning of the PageLoad code, but I still need to visit another page / come back to see the changes.
Any ideas?
Thanks.
Thank you for your replies. I'm using a ListView:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataSetTableAdapters.SelectFriendsTableAdapter sdt = new DataSetTableAdapters.SelectFriendsTableAdapter();
DataTable tab = sdt.SelectFriends();
ListView1.DataSource = tab;
ListView1.DataBind();
}
}
, so the ListView content should get updated.
If you don't want to refresh the page and you're using asp.net webforms you can use an UpdatePanel and place all your controls inside of it, etc... That will keep the changes made in the form / display when you submit the info. I'm assuming the form is on submitting the changed/new data as you didn't specifically state how the data was being updated/changed.
If you don't want to use an update panel, then when the page is posting back you will have to set the values for the UI controls that you want to update with the values from the 'newFriend' object (I'm assuming that has the changed values).
Found it!
The solution for this issue is to add this code at the end of your submit button click event:
Server.Transfer("currentpage.aspx");
As far as I understand, Response.Redirect("http://stackoverflow.com"); tells the browser to initiate a request to another URL.
One of the results of this is that the browser "remembers" the redirection, and allows pressing "back."
However, I have a website where Response.Redirect disables the ability to press the browser's "Back" button, as if the browser had opened a new window. (Browsing history is not forgotten, unlike with Server.Transfer.)
The redirection used to work properly in the past, so I suspect the problem has something to do with the IIS server (IIS7).
I apologize in advance if this question should be moved to ServerFault.com.
UPDATES:
Here is some code:
protected void btnClickMe_Click(object sender, EventArgs e)
{
// ...
// some server-side logic
// ...
Response.Redirect("NewPage.aspx?ProductID=" + idNum);
}
Regarding "disables the ability to press the browser's 'Back' button", what I meant is that the button cannot be pressed. Same as when you open a new window. The button is gray, and clicking it has absolutely no effect.
UPDATE 2:
This has been tested with IE6 and IE8.
The problem was NOT with the Response.Redirect();.
When I was on OldPage.aspx, I entered a new URL in the address bar. Once the browser loaded the new site, it disabled the back-button.
Conclusion: There is something wrong with OldPage.aspx, not the redirection to NewPage.aspx.
I still don't know why THIS happens, but this is an entirely different question.
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack) //check if the webpage is loaded for the first time.
{
ViewState["PreviousPage"] =
Request.UrlReferrer;//Saves the Previous page url in ViewState
}
}
protected void btnBack_Click(object sender, EventArgs e)
{
if (ViewState["PreviousPage"] != null) //Check if the ViewState
//contains Previous page URL
{
Response.Redirect(ViewState["PreviousPage"].ToString());//Redirect to
//Previous page by retrieving the PreviousPage Url from ViewState.
}
}