I have a image verifier in oUpWizStep2 update panel of wizard steps 2. I wan to refresh the image through Page_PreRender but i get JavaScript runtime error: 'RefreshImageVerifier' is undefined. It works fine in others page without wizard steps.
my code below
Private Sub Page_PreRender(sender As Object, e As EventArgs) Handles Me.PreRender
If Wizard1.ActiveStepIndex = 1 Then
Dim oUp As UpdatePanel = TryCast(Wizard1.FindControl("oUpWizStep2"), UpdatePanel)
Dim imgVerifier As ImageVerifier = CType(Wizard1.FindControl("ImgVerifierS2"), ImageVerifier)
' ## Refresh the verification code on call back.
ScriptManager.RegisterStartupScript(oUpWizStep2, oUpWizStep2.GetType, "scriptname", "RefreshImageVerifier('" & imgVerifier.ClientID & "','ImageVerifier.axd?uid=" & imgVerifier.MyUniqueID & "');", True)
End If
End Sub
Related
I Have 2 Pages of ASP V4.5 which are Login.aspx as a starting page and contentMainpage.aspx.
It's working when I've tested on debug mode in visual studio 2012, but when I try to deploy it on IIS the button log in is not responding redirect to another page.
The problem can be on web configuration
I try to google it for 2 days and can not get the solution right.
Please help.
here the code bellow:
Imports PurchaseOrderList.Class1
Public Class Login
Inherits System.Web.UI.Page
Dim abmPO As New ServiceReference1.Service1SoapClient
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Session("LoginName") = ""
End Sub
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
If IsPostBack Then
Dim LoginAutentif As New PurchaseOrderList.Class1
If (LoginAutentif.ValidatePassword(Trim(TxtLoginName.Text), Trim(TxtPassW.Text))) = 0 Then
LblErrorMessage.Visible = True
LblErrorMessage.Text = "Invalid User Name or User Password"
Exit Sub
Else
If (Response.IsClientConnected) Then
Response.Redirect("~/PurchaseOrderHeaders.aspx", False)
Session("LoginName") = TxtLoginName.Text
End If
End If
End If
Catch ex As Exception
End Try
End Sub
End Class
Maybe try to "return Response.Redirect". I had this problem in MVC5.
Your issue is most likely to do with this line:
If (Response.IsClientConnected) Then
Quick google suggests there may be a few issues with IIS7/7.5 and using this property. Also I don't think it's really necessary here, it would make more sense being used in a long running routine to detect a client disconnect or timeout.
Try changing you button click to the following and see how you go.
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
If IsPostBack Then
Dim LoginAutentif As New PurchaseOrderList.Class1
If (LoginAutentif.ValidatePassword(Trim(TxtLoginName.Text), Trim(TxtPassW.Text))) = 0 Then
LblErrorMessage.Visible = True
LblErrorMessage.Text = "Invalid User Name or User Password"
Exit Sub
Else
Session("LoginName") = TxtLoginName.Text
Response.Redirect("~/PurchaseOrderHeaders.aspx", True)
End If
End If
Catch ex As Exception
End Try
End Sub
I have a relatively simple ASP.NET problem (I should think) that regrettably I am unable to solve by myself. What I am trying to do is the following:
On a page I load a number of controls (Text Boxes) programmatically;
following this load the user should be able to select a value to load into the Textbox from a panel control that is added to the page following the click of a button
Once the panel is closed, the selected text from the panel should be loaded into the textbox
However, in the vb.net statements below when run the "test" string never makes it to the textbox - any help with resolving this would be greatly appreciated.
Public Class test
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Controls_Load()
End Sub
Public Sub Controls_Load()
Dim ttf_tb As New TextBox With {.ID = "ttf_tb"}
Master_Panel.Controls.Add(ttf_tb)
Dim ttf_button As New Button
Master_Panel.Controls.Add(ttf_button)
AddHandler ttf_button.Click, AddressOf TTF_BUTTON_CLICK
End Sub
Public Sub TTF_BUTTON_CLICK(sender As Object, e As EventArgs)
Dim str As String = sender.id
Dim panel As New Panel
panel.ID = "TTF_Panel"
panel.Width = 300
panel.Height = 300
Master_Panel.Controls.Add(panel)
panel.BackColor = Drawing.Color.Black
panel.Style.Add(HtmlTextWriterStyle.Position, "absolute")
panel.Style.Add(HtmlTextWriterStyle.Left, "200px")
panel.Style.Add(HtmlTextWriterStyle.Top, "100px")
panel.Style.Add(HtmlTextWriterStyle.ZIndex, "100")
Dim CL_Button As New Button
CL_Button.ID = "TTF_Close_" & Replace(str, "TTF_Button_", "")
panel.Controls.Add(CL_Button)
AddHandler CL_Button.Click, AddressOf TTF_Close_Button_Click
End Sub
Public Sub TTF_Close_Button_Click(sender As Object, e As EventArgs)
Dim ttf_tb As TextBox = Master_Panel.FindControl("ttf_tb")
ttf_tb.Text = "Test"
Dim panel As Panel = FindControl("TTF_Panel")
Master_Panel.Controls.Remove(panel)
End Sub
End Class
I think you need to re-create your controls in the Page_Init method. It's been a while since I've done web forms but I think it's something like:
When a user clicks the button a post back is fired. This re-creates a new instance of your class, creates the controls on the page, assigns any form values then calls your Page_Load event.
The problem is you are creating your controls too late, so the forms values are never assigned correctly.
You should create / recreate your dynamic controls in the Init event:
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
Controls_Load()
End Sub
This should allow you to maintain their state across PostBacks.
For more information about this topic, see the MSDN article on the ASP.NET Page Life Cycle.
I swear I have a love hate relationship with Microsoft. This is being thrown only in IE 10.
Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/>
Now,
On the #page I have ValidateRequest = "False"
In the Web.config I have httpRuntime requestValidationMode="2.0"
I am NOT using any Ajax or have a ScriptManager
I am checking for PostBack
Removed combobox code but it does use AutoPostBack
Here is my code
Private Sub Page_Init(sender As Object, e As EventArgs) Handles Me.Init
Try
Dim User As New UserRole(Me.SiteID, Master.UserName)
If User.GetLevel(Permissions.Edit) >= Levels.Page Then
Exit Sub
End If
Catch ex As Exception
End Try
Response.Redirect("/Manage/Errors/Unauthorized.aspx")
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Me.IsPostBack = True Then
Exit Sub
End If
Try
Dim Item As New PageBase(Me.PageID)
Me.txtCode.Text = Item.Code
Catch ex As Exception
Master.ShowError("Flex encountered a problem reading this page.")
End Try
End Sub
Private Sub cmbSnippet_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmbSnippet.SelectedIndexChanged
If Me.cmbSnippet.SelectedIndex = 0 Then
Exit Sub
End If
Try
Dim Filename As String = String.Format("/Manage/Editors/Text/Scripts/{0}", Me.cmbSnippet.SelectedValue)
Me.txtCode.Text = My.Computer.FileSystem.ReadAllText(Server.MapPath(Filename))
Exit Sub
Catch ex As Exception
End Try
Master.ShowError("Flex encountered a problem reading the snippet.")
End Sub
Private Sub btnOk_Click(sender As Object, e As EventArgs) Handles btnOk.Click
Try
Dim Item As New PageBase(Me.PageID)
Item.Code = Me.txtCode.Text
If Item.Update = True Then
Me.ShowUpdateTime()
Exit Sub
End If
Catch ex As Exception
End Try
Master.ShowError("Flex encountered a problem modifying this page.")
End Sub
Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click
Response.Redirect(String.Format("/Manage/Preview.aspx?PageID={0}", Me.PageID))
End Sub
This may or may not solve the issue.
.NET 4 and earlier don't know what IE 10 is. It's not in the list of browsers .NET knows about, so .NET assumes the browser is something that can't handle...well, anything really. Javascript and cookies, and I suspect more, get screwed over. So:
Download this: http://www.hanselman.com/blog/content/binary/App_BrowsersUpdate.zip, which is taken from here:
http://www.hanselman.com/blog/BugAndFixASPNETFailsToDetectIE10CausingDoPostBackIsUndefinedJavaScriptErrorOrMaintainFF5ScrollbarPosition.aspx,
which is referenced from here: IE10 User-Agent causes ASP.Net to not send back Set-Cookie (IE10 not setting cookies)
Extract the files and put them in your application's App_Browser directory. Rebuild and see if that works.
On my page I have this button, which calls this method, it works. However, when I set that same method, to be called during Page Load it works, but not completely. The method has a few readers, they read from the database and show the information, there's no issue when the method is ran reguarly, but on Page Load the readers never read.
This is one my select statements that fuel the reader:
sql.CommandText = "select temp from forecast where zone='" + myzone + "' and date=TO_DATE('" + mydate + "','dd/mm/yyyy') order by zone,date,time"
sql.CommandType = CommandType.Text
reader = sql.ExecuteReader()
Dim x As Integer
While (reader.Read())
data(0, x) = reader.Item("temp").ToString()
x += 1
End While
Again, when ran as a button click once the page is loaded it reads, when ran during Page Load it doesn't read.
It cannot be the select statement since the same exact statement works when the button is clicked. Also both variables are working and have the values they should when the statement is executed during Page Load so it can't be that either. Also tried with both Load and Init and none will work.
My Button Click:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.myMethod()
End Sub
And the Page Load:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.myMethod()
End Sub
Any ideas of what I may be doing wrong? Thanks!
Can I get some help posting across different pages from a custom control?
I've created a custom button that raises it's own click event through the following code:
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Const EventName As String = "button_click"
Const ArgName As String = "__EVENTARGUMENT"
If Page.IsPostBack _
AndAlso Request.Params IsNot Nothing _
AndAlso Request.Params(ArgName).Trim = EventName Then
Me.OnClick(Me.this_button, New EventArgs)
Else
Me.this_button.Attributes.Add("OnClick", Page.ClientScript.GetPostBackEventReference(Me.this_button, EventName))
End If
End Sub
How would I go about modifying this to let me post to a different page?
I'd like it to act as close as possible to the System.Web.UI.WebControls.Button property PostBackUrl.
You can use Cross Page Postbacks.
You can also use the WebForm_DoPostBackWithOptions js method to postback the current page to another page.